On Wed, Jun 3, 2026 at 4:07 AM Andrew Pinski <[email protected]> wrote: > > EVRP changes some statements into copies but then does > not do copy prop during its handling. This causes in some > cases where phiopt could have optimized the phi not to be > done. So we should move the copy prop pass (sccopy) right > after evrp instead of after phiopt. > > Notes on the testsuite changes: > dse-points-to.c needs to disable sccopy1 for the same > reason why it disables all other copyprop passes. > pr45397.c had an xfail for specifically PR 103221. > pr81981.c is about a missing warning, in this case moving > sccopy swaps around which uses is first in the list.
OK. I guess EVRP copies are more common than tail-recursion introduced ones. > Bootstrapped and tested on x86_64-linux-gnu. > > PR tree-optimization/103221 > gcc/ChangeLog: > > * passes.def (early_optimizations): Move sccopy > to after evrp. > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/dse-points-to.c: Disable sccopy1. > * gcc.dg/tree-ssa/pr45397.c: Remove the xfail. > * gcc.dg/ubsan/pr81981.c: Swap around which one is xfailed. > > Signed-off-by: Andrew Pinski <[email protected]> > --- > gcc/passes.def | 2 +- > gcc/testsuite/gcc.dg/tree-ssa/dse-points-to.c | 2 +- > gcc/testsuite/gcc.dg/tree-ssa/pr45397.c | 8 +++----- > gcc/testsuite/gcc.dg/ubsan/pr81981.c | 4 ++-- > 4 files changed, 7 insertions(+), 9 deletions(-) > > diff --git a/gcc/passes.def b/gcc/passes.def > index cdddb87302f..1fc867fae51 100644 > --- a/gcc/passes.def > +++ b/gcc/passes.def > @@ -94,6 +94,7 @@ along with GCC; see the file COPYING3. If not see > NEXT_PASS (pass_phiprop); > NEXT_PASS (pass_fre, true /* may_iterate */); > NEXT_PASS (pass_early_vrp); > + NEXT_PASS (pass_sccopy); > NEXT_PASS (pass_merge_phi); > NEXT_PASS (pass_dse); > NEXT_PASS (pass_cd_dce, false /* update_address_taken_p */, true /* > remove_unused_locals */); > @@ -104,7 +105,6 @@ along with GCC; see the file COPYING3. If not see > NEXT_PASS (pass_tail_recursion); > NEXT_PASS (pass_if_to_switch); > NEXT_PASS (pass_convert_switch); > - NEXT_PASS (pass_sccopy); > NEXT_PASS (pass_profile); > NEXT_PASS (pass_local_pure_const); > NEXT_PASS (pass_modref); > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/dse-points-to.c > b/gcc/testsuite/gcc.dg/tree-ssa/dse-points-to.c > index 762d6720143..ff84ba8db13 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/dse-points-to.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/dse-points-to.c > @@ -1,5 +1,5 @@ > /* { dg-do compile } */ > -/* { dg-options "-O2 -fno-tree-ccp -fno-tree-forwprop -fno-tree-fre > -fno-tree-vrp -fdump-tree-dse1-details" } */ > +/* { dg-options "-O2 -fno-tree-ccp -fno-tree-forwprop -fno-tree-fre > -fno-tree-vrp -fdisable-tree-sccopy1 -fdump-tree-dse1-details" } */ > > int > f () > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr45397.c > b/gcc/testsuite/gcc.dg/tree-ssa/pr45397.c > index 8eacb518777..37e57a8996c 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/pr45397.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr45397.c > @@ -18,12 +18,10 @@ int foo_mul (const unsigned char *tmp, int i, int val) > > /* All cases should end up using min/max for the saturated operations and > have no control flow. */ > -/* EVRP leaves copies in the IL which confuses phiopt1 so we have > - to rely on phiopt2 instead. */ > /* { dg-final { scan-tree-dump-not " & 255;" "evrp" } } */ > -/* { dg-final { scan-tree-dump-times "MAX_EXPR" 3 "phiopt1" { xfail *-*-* } > } } */ > -/* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" { xfail *-*-* } > } } */ > -/* { dg-final { scan-tree-dump-not "if " "phiopt1" { xfail *-*-* } } } */ > +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 3 "phiopt1" } } */ > +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ > +/* { dg-final { scan-tree-dump-not "if " "phiopt1" } } */ > /* { dg-final { scan-tree-dump-times "MAX_EXPR" 3 "phiopt2" } } */ > /* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt2" } } */ > /* { dg-final { scan-tree-dump-not "if " "phiopt2" } } */ > diff --git a/gcc/testsuite/gcc.dg/ubsan/pr81981.c > b/gcc/testsuite/gcc.dg/ubsan/pr81981.c > index d201efb3f65..8aac5ae9725 100644 > --- a/gcc/testsuite/gcc.dg/ubsan/pr81981.c > +++ b/gcc/testsuite/gcc.dg/ubsan/pr81981.c > @@ -16,6 +16,6 @@ foo (int i) > u[0] = i; > } > > - v = u[0]; /* { dg-warning "may be used uninitialized" "" { > xfail *-*-* } } */ > - return t[0]; /* { dg-warning "may be used uninitialized" } */ > + v = u[0]; /* { dg-warning "may be used uninitialized" } */ > + return t[0]; /* { dg-warning "may be used uninitialized" "" { > xfail *-*-* } } */ > } > -- > 2.43.0 >
