[Bug middle-end/86554] [7/8/9 Regression] Incorrect code generation with signed/unsigned comparison
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jul 18 08:12:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86554
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |6.4.0
Summary|Incorrect code generation |[7/8/9 Regression]
|with signed/unsigned |Incorrect code generation
|comparison |with signed/unsigned
| |comparison
Known to fail|7.0.1 |7.1.0, 8.1.0, 9.0
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
This regressed with moving fold-const.c patterns to match.pd, specifically
/* Non-equality compare simplifications from fold_binary */
(for cmp (lt gt le ge)
/* Comparisons with the highest or lowest possible integer of
the specified precision will have known values. */
(simplify
(cmp (convert?@2 @0) INTEGER_CST@1)
...
(if (cmp == LE_EXPR)
{ constant_boolean_node (true, type); })
and
/* Transform comparisons of the form X +- C1 CMP C2 to X CMP C2 -+ C1. */
(for cmp (lt le gt ge)
(for op (plus minus)
rop (minus plus)
(simplify
(cmp (op@3 @0 INTEGER_CST@1) INTEGER_CST@2)
...
(if (single_use (@3))
(with
{
fold_overflow_warning (("assuming signed overflow does not occur "
"when changing X +- C1 cmp C2 to "
"X cmp C2 -+ C1"),
WARN_STRICT_OVERFLOW_COMPARISON);
}
(cmp @0 { res; })))))))))
The latter only appeared with GCC7.
The issue itself is latent at least since match-and-simplify but possibly
earlier as well where SCCVN used GENERIC expression simplification for
"combining" stmt defs.
It will take some time to fix this (if a fix is possible with reasonable
amount of work), do not hold your breath.
More information about the Gcc-bugs
mailing list