https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106677
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=94234
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
One thing I Noticed:
_43 = foo_6(D) + 24;
...
_41 = _54 + 24;
if (_41 != _43)
There is a pattern if the lhs of pointer_plus is the same but not if the rhs is
the same.
the patterns (:2789):
```
/* And similar for pointers. */
(for op (eq ne)
(simplify
(op (pointer_plus @0 @1) (pointer_plus @0 @2))
(op @1 @2)))
(simplify
(pointer_diff (pointer_plus @0 @1) (pointer_plus @0 @2))
(if (TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1)))
(convert (minus @1 @2))))
```
I don't know if that will help here though.
Note there is the pointer_diff pattern for this further down:
```
(simplify
(pointer_diff (pointer_plus @0 @2) (pointer_plus @1 @2))
(pointer_diff @0 @1))
(simplify
(pointer_diff (pointer_plus @@0 @1) (pointer_plus @0 @2))
/* The second argument of pointer_plus must be interpreted as signed, and
thus sign-extended if necessary. */
(with { tree stype = signed_type_for (TREE_TYPE (@1)); }
/* Use view_convert instead of convert here, as POINTER_PLUS_EXPR
second arg is unsigned even when we need to consider it as signed,
we don't want to diagnose overflow here. */
(minus (convert (view_convert:stype @1))
```
So adding one for ne/eq should be ok too. Let me see if it helps this case.