[Bug tree-optimization/80541] Wrong constant folding
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Apr 27 08:37:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80541
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
CCP with bit-tracking:
Visiting statement:
# RANGE [-1, 0]
_4 = (long int) b_10;
which is likely CONSTANT
Lattice value changed to VARYING. Adding SSA edges to worklist.
Visiting statement:
# RANGE [0, 9223372036854775807] NONZERO 0
_5 = _4 * -9223372036854775808;
which is likely CONSTANT
Applying pattern match.pd:844, gimple-match.c:90
Lattice value changed to CONSTANT 0. Adding SSA edges to worklist.
marking stmt to be not simulated again
this is bit_value_binop at work which IMHO is correct -- -1 * LONG_MIN
is invoking undefined behavior so _4 can only be zero and thus _5 is zero.
So the error happens earlier, somewhere in GENERIC folding where we transform
the initial expression to
int x = (int) (1 % ((long int) b * -9223372036854775808(OVF) +
9223372036854775807));
which is from fold_plusminusmult where we fold
b + (b * LONG_MAX) to b * (1 + LONG_MAX).
Thus this is effectively a duplicate of PR66313 (just a case that should
be obvious).
More information about the Gcc-bugs
mailing list