tree-optimization/107699 - missed &data._M_elems + _1 != &data._M_elems folding
authorRichard Biener <rguenther@suse.de>
Thu, 8 Dec 2022 08:07:36 +0000 (09:07 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 8 Dec 2022 10:58:47 +0000 (11:58 +0100)
commit892e8c520be37d0a0f14e2ae375103c5303ed549
tree8a8030495b65c9fdd64db3049263cf47e6f32b9c
parent4505270128ef70538ea345f292e3eb85a5369eaf
tree-optimization/107699 - missed &data._M_elems + _1 != &data._M_elems folding

The following addresses a missed folding noticed in PR107699 that can
be fixed amending the existing &x + a != &x + b pattern to also handle
the case of only one side having a pointer plus.  I'm moving the
patterns next to related simpifications showing there'd be an existing
pattern matching this if it were not gated with an explicit single_use
constraint.  Note the new pattern also handles &x.a + a != &x.b, but
this hints at some unification / generalization opportunities here.

PR tree-optimization/107699
* match.pd (&a !=/== &a.b + c -> (&a - &a.b) !=/== c): New
pattern variant.

* gcc.dg/tree-ssa/pr107699.c: New testcase.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/pr107699.c [new file with mode: 0644]