]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
passes: Move early pass_sccopy right after evrp [PR103221]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Tue, 2 Jun 2026 20:21:11 +0000 (13:21 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Wed, 3 Jun 2026 16:18:24 +0000 (09:18 -0700)
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 <andrew.pinski@oss.qualcomm.com>
gcc/passes.def
gcc/testsuite/gcc.dg/tree-ssa/dse-points-to.c
gcc/testsuite/gcc.dg/tree-ssa/pr45397.c
gcc/testsuite/gcc.dg/ubsan/pr81981.c

index cdddb87302f647b4709b246b84cb5766230c6a97..1fc867fae51771ded5dc7dc0fe73dcdd421d5e65 100644 (file)
@@ -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);
index 762d672014338ab8d3ff95f5e4aa5734965828be..ff84ba8db13a8e1b73e2ec60ed43c2d8b4f87907 100644 (file)
@@ -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 ()
index 8eacb5187773b530ea89cfc39c8d1f1e06ef7958..37e57a8996c14e80863f0f898828d3df1850b910 100644 (file)
@@ -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" } } */
index d201efb3f65fd8af6d3b8189cb4122ba4b66f49b..8aac5ae9725e019c275512fec4fdab03c4368d56 100644 (file)
@@ -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 *-*-* } } */
 }