https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116835
Bug ID: 116835 Summary: phiprop will prop back into a loop Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: pinskia at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Blocks: 116821, 116824 Target Milestone: --- Take: ``` struct Foo { int **p; int **q; }; struct Foo1 { int t[4]; }; int bar (int b, int c, int d, struct Foo1 *aa) { int *p = &c; for (int j = 0; j < 4; ++j) { p = &aa->t[j]; } return *p; } ``` phiprop1 does: ``` Inserting PHI for result of load _6 = *p_1; for edge defining &c inserting load _4 = c; for edge defining p_8 inserting load _3 = *p_8; _6 = PHI <_4(2), _3(3)> Removing dead stmt:p_1 = PHI <&c(2), p_8(3)> ``` But this is moving the load into the loop which seems wrong and might cause other issues. I am running into a regression due to this when fixing PR 116821 . PR 116824 will cause this to show up more too. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116821 [Bug 116821] phiprop could be improved to handle PHI<&a, ssa_name> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116824 [Bug 116824] phiprop gets confused with vop phi