This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/30911] VRP fails to eliminate range checks in Ada code



------- Comment #40 from baldrick at free dot fr  2007-03-01 23:07 -------
Subject: Re:  VRP fails to eliminate range checks in Ada code

The problem is in this transformation:

      /* Fold (X & C) op (Y & C) as (X ^ Y) & C op 0", and symmetries.  */

X^Y may not be in the range of the type.  In this case C=7 and op=NE_EXPR.
The type of X and Y has range 4..5.  Thus X^Y is either 0 or 2 (neither of
which is in the range 4..5).  Since the type of X^Y has range 4..5, the
new fold code deduces that X^Y NE 0 is always true.  I think the thing to
do, as Richard Kenner suggested, is to convert each type to its base type
right at the start of fold_comparison, at least if it has a base type
(the same goes for other routines in fold).  This unfortunately neutralizes
your patch, since as it is right now you will only ever see base types.
Thus this kind of check needs to happen at the start of fold_comparison,
before the conversion to the base type.

Ciao,

Duncan.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30911


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]