aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2023-10-19 13:44:01 +0100
committerTamar Christina <tamar.christina@arm.com>2023-10-19 13:44:01 +0100
commit217a0fcb852aeb4aa9e3fb9baec6ff947c8de3d4 (patch)
treed2b11236f78ee8c8b518c4de60c9f655ecb0b864 /gcc/testsuite
parentbeab5b95c581452adeb26efd59ae84a61fb3b429 (diff)
downloadgcc-217a0fcb852aeb4aa9e3fb9baec6ff947c8de3d4.zip
gcc-217a0fcb852aeb4aa9e3fb9baec6ff947c8de3d4.tar.gz
gcc-217a0fcb852aeb4aa9e3fb9baec6ff947c8de3d4.tar.bz2
middle-end: don't create LC-SSA PHI variables for PHI nodes who dominate loop
As the testcase shows, when a PHI node dominates the loop there is no new definition inside the loop. As such there would be no PHI nodes to update. When we maintain LCSSA form we create an intermediate node in between the two loops to thread alongt the value. However later on when we update the second loop we don't have any PHI nodes to update and so adjust_phi_and_debug_stmts does nothing. This leaves us with an incorrect phi node. Normally this does nothing and just gets ignored. But in the case of the vUSE chain we end up corrupting the chain. As such whenever a PHI node's argument dominates the loop, we should remove the newly created PHI node after edge redirection. The one exception to this is when the loop has been versioned. In such cases the versioned loop may not use the value but the second loop can. When this happens and we add the loop guard unless the join block has the PHI it can't find the original value for use inside the guard block. The next refactoring in the series moves the formation of the guard block inside peeling itself. Here we have all the information and wouldn't need to re-create it later. gcc/ChangeLog: PR tree-optimization/111860 * tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg): Remove PHI nodes that dominate loop. gcc/testsuite/ChangeLog: PR tree-optimization/111860 * gcc.dg/vect/pr111860.c: New test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr111860.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/pr111860.c b/gcc/testsuite/gcc.dg/vect/pr111860.c
new file mode 100644
index 0000000..36f0774
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr111860.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+int optimize_path_n, optimize_path_d;
+int *optimize_path_d_0;
+extern void path_threeOpt( long);
+void optimize_path() {
+ int i;
+ long length;
+ i = 0;
+ for (; i <= optimize_path_n; i++)
+ optimize_path_d = 0;
+ i = 0;
+ for (; i < optimize_path_n; i++)
+ length += optimize_path_d_0[i];
+ path_threeOpt(length);
+}