This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix overzealous folding
> The problem seems to be caused by adjust_range_with_scev (after applying
> the patch I posted). If I remove that from VRP the test is retained.
D.1367_13 = (boolean) i_29;
i_29 is an iv running from 1 to 10 so SCEV computes that D.1367_13 >= 1.
When the statement is passed to extract_range_from_unary_expr, it detects a
truncation so sets the range to VARYING. But extract_range_from_expr decides
that it can do better and calls set_value_range_to_nonnegative to set it to
[0, TYPE_MAX_VALUE], i.e. [0,1]. Therefore D.1367_13 is computed as being 1.
All of this is entirely consistent within SCEV and VRP, but incompatible with
the folding made by fold_unary. I presume the C family of languages doesn't
see the problem because of the guard for BOOLEAN_TYPE. Extending it further
to ENUMERAL_TYPE seems quite harmless and safe...
--
Eric Botcazou