https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63184
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|rguenth at gcc dot gnu.org |pinskia at gcc dot
gnu.org
--- Comment #26 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So what is interesting is for aarch64, GCC is able to figure out the two values
are equal but only after register allocation (note LLVM has a similar issue
too).
Anyways at forwprop4 we have:
_5 = &a[1] + _4;
_13 = _3 + 8;
_7 = &a + _13;
if (_5 != _7)
I think I have a patch (I need to format it correctly though):
(for neeq (ne eq)
(simplify
(neeq (pointer_plus ADDR_EXPR@0 @1) (pointer_plus ADDR_EXPR@2 @3))
(with { poly_int64 diff; }
(if (ptr_difference_const (@0, @2, &diff))
(neeq (plus { build_int_cst_type (type, diff); }
(convert (minus @1 @3)))
{build_zero_cst (type); })))))
I also added this one too as I saw that was not being folded either:
(simplify
(pointer_diff (pointer_plus ADDR_EXPR@0 @1) (pointer_plus ADDR_EXPR@2 @3))
(with { poly_int64 diff; }
(if (ptr_difference_const (@0, @2, &diff))
(plus { build_int_cst_type (type, diff); } (convert (minus @1 @3))))))