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

Drea Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2026-11-29

--- Comment #1 from Drea Pinski <pinskia at gcc dot gnu.org> ---
>  - gcc 7.5 is correct.

not at -O2 though. But GCC 5.5.0 is correct at -O2.


So from the looks of it, the cast is being moved past the neg and that is what
is causing the issue.

And then this match pattern is causing the issue.
```
/* -A CMP -B -> B CMP A.  */
(for cmp (tcc_comparison)
     scmp (swapped_tcc_comparison)
 (simplify
  (cmp (negate @0) (negate @1))
  (if (FLOAT_TYPE_P (TREE_TYPE (@0))
       || (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0))
           && (cmp == EQ_EXPR
               || cmp == NE_EXPR
               || TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))))
   (scmp @0 @1)))
 (simplify
  (cmp (negate @0) CONSTANT_CLASS_P@1)
  (if (FLOAT_TYPE_P (TREE_TYPE (@0))
       || (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0))
           && (cmp == EQ_EXPR
               || cmp == NE_EXPR
               || TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))))
   (with { tree tem = const_unop (NEGATE_EXPR, TREE_TYPE (@0), @1); }
    (if (tem && !TREE_OVERFLOW (tem))
     (scmp @0 { tem; }))))))
```
But that match pattern is ok, the problem is before hand.

Let me try to get a testcase without needing this match pattern.

Reply via email to