[Bug tree-optimization/85588] [6/7/8/9 Regression] -fwrapv miscompilation
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu May 3 12:17:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85588
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Or rather
Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c (revision 259879)
+++ gcc/fold-const.c (working copy)
@@ -474,12 +474,15 @@ negate_expr_p (tree t)
case EXACT_DIV_EXPR:
if (TYPE_UNSIGNED (type))
break;
- if (negate_expr_p (TREE_OPERAND (t, 0)))
+ /* In general we can't negate A in A / B, because if A is INT_MIN and
+ B is not 1 we change the sign of the result. */
+ if (TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST
+ && negate_expr_p (TREE_OPERAND (t, 0)))
return true;
/* In general we can't negate B in A / B, because if A is INT_MIN and
B is 1, we may turn this into INT_MIN / -1 which is undefined
More information about the Gcc-bugs
mailing list