Isn't it possible to attach some information on a comparison
statement that tells code generation never to never
optimize away this particular comparison even if it
seems to be able to prove it is always true or false?
(just like volatile does for memory read)

For code executed after this kind of comparison code generation (except
other of such comparison) can of course assume information gained from
the comparison, so we get the best of both world.

Laurent

On Fri, 2005-08-12 at 22:08 +0200, Kai Henningsen wrote:
> [EMAIL PROTECTED] (Richard Kenner)  wrote on 12.08.05 in <[EMAIL PROTECTED]>:
> 
> > What has to happen is that we need some sort of way of indicating that it's
> > not permissible to derive information through a particular conversion.
> 
> That may be the only practical solution, but it seems to me it's not the  
> perfect solution.
> 
> The point is that there are two different kinds of value range  
> calculations. You have value range information from program flow, and you  
> have value range information from types.
> 
> You want 'Valid optimization to ignore range information from types,  
> because that's what you're checking for in the first place.
> 
> On the other hand, you *want* to use range information from program flow.  
> For example, if you just assigned a constant, you *know* the exact range  
> of the thing. Or maybe you already passed a program point where any out-of- 
> range value would have been caught by an implicit 'Valid. It could  
> optimize away a lot of implicit 'Valid checks done, say, on the same  
> variable used as an array index multiple times.
> 
> Now that is certainly nontrivial to implement, and may not be worth it for  
> gcc. But I believe it would be better than the other way.
> 
> MfG Kai
> 

Reply via email to