From: Andrew Pinski Date: Tue, 2 Jun 2026 20:21:11 +0000 (-0700) Subject: passes: Move early pass_sccopy right after evrp [PR103221] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef63be5d8ae087f2805dd28d2bae9ac3eb5bd02c;p=thirdparty%2Fgcc.git passes: Move early pass_sccopy right after evrp [PR103221] 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. 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 --- 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 *-*-* } } */ }