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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-11-24
          Component|middle-end                  |tree-optimization
           Keywords|                            |missed-optimization
             Blocks|110287                      |
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This should have been even folded during CCP1.

```
/* For equality and subtraction, this is also true with wrapping overflow.  */
(for op (eq ne minus)
 (simplify
  (op (plus:c @0 @2) (plus:c @1 @2))
  (if (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0))
       && (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0))
           || TYPE_OVERFLOW_WRAPS (TREE_TYPE (@0))))
   (op @0 @1))))
```

Should be extended for PointerPlus or done for it.

That is:
```
(for op  (eq ne)
 (simplify
  (op (pointer_plus @0 @1) (pointer_plus @0 @2))
  (op @1 @2))

```

That should fix it during CCP1 (and fre).


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110287
[Bug 110287] _M_check_len is expensive

Reply via email to