https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110134

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
r6-1814-g66e1cacf608045 caused GCC 6 to stop doing both.
Because they were considered redundant with the patterns added by:
r6-1113-g534bd33b61d08e

Which was mostly true.

I think forwprop was working again with r8-2194-g4f450a2b102212 for f2 (I am
not 100% sure).

So to summarize r6-1814-g66e1cacf608045 removed the unsigned/wrapping case for
NE/EQ since it was originally thought as redundant. My patch adds support back
for those 2.

case EQ_EXPR:
case NE_EXPR:
...

-      /* Similarly for a NEGATE_EXPR.  */
-      if (TREE_CODE (arg0) == NEGATE_EXPR
-         && TREE_CODE (arg1) == INTEGER_CST
-         && 0 != (tem = negate_expr (fold_convert_loc (loc, TREE_TYPE (arg0),
-                                                       arg1)))
-         && TREE_CODE (tem) == INTEGER_CST
-         && !TREE_OVERFLOW (tem))
-       return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), tem);

...

-      /* Fold -X op -Y as X op Y, where op is eq/ne.  */
-      if (TREE_CODE (arg0) == NEGATE_EXPR
-          && TREE_CODE (arg1) == NEGATE_EXPR)
-       return fold_build2_loc (loc, code, type,
-                               TREE_OPERAND (arg0, 0),
-                               fold_convert_loc (loc, TREE_TYPE (arg0),
-                                                 TREE_OPERAND (arg1, 0)));


Since these 2 did cases didn't test TYPE_OVERFLOW_UNDEFINED, we should handle
EQ/NE also in match.pd the same way.

Reply via email to