tree-optimization/89317 - missed folding of (p + 4) - &p->d
authorRichard Biener <rguenther@suse.de>
Sun, 11 Dec 2022 13:07:34 +0000 (14:07 +0100)
committerRichard Biener <rguenther@suse.de>
Sun, 11 Dec 2022 13:45:30 +0000 (14:45 +0100)
commitd13b86f932ff7b9d8f41483fd869c637b67d4dec
treed7ea798473c10c4812bd69a4331b03bf4c3dc7a4
parent26295a069fd312a8be4a6cd96643117383145cc0
tree-optimization/89317 - missed folding of (p + 4) - &p->d

The PR notices we fail to simplify

  a_4 = &x_3(D)->data;
  b_5 = x_3(D) + 16;
  _1 = b_5 - a_4;

together with the enabler handling ADDR_EXPR leafs in separate
stmts in match.pd the suggested patterns work.

PR tree-optimization/89317
* match.pd ((p + b) - &p->c -> b - offsetof(c)): New patterns.

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