diff mbox series

[3/7] Don't skip renaming PHIs in loop nest with only one inner loop

Message ID DB5PR0801MB2742518C4D641E01C96D86F2E7700@DB5PR0801MB2742.eurprd08.prod.outlook.com
State New
Headers show
Series [1/7] Delete unused field of struct partition in loop distribution | expand

Commit Message

Bin Cheng Oct. 5, 2017, 1:16 p.m. UTC
Hi,
Function rename_variables_in_bb skips renaming PHI nodes in loop nest if the
outer loop has only one inner loop.  This breaks loop nest distribution when
inner loop has PHI node initialized from outer loop's variable.  Unfortunately,
I lost the original C code illustrating the issue.  Now it is only triggered
in building spec2006/416.gamess with loop nest distribution, but I failed to
reduce a test from it.
Bootstrap and test in patch set on x86_64 and AArch64, is it OK?

Thanks,
bin
2017-10-04  Bin Cheng  <bin.cheng@arm.com>

	* tree-vect-loop-manip.c (rename_variables_in_bb): Rename PHI nodes
	when copying loop nest with only one inner loop.

Comments

Richard Biener Oct. 9, 2017, 1:33 p.m. UTC | #1
On Thu, Oct 5, 2017 at 3:16 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> Function rename_variables_in_bb skips renaming PHI nodes in loop nest if the
> outer loop has only one inner loop.  This breaks loop nest distribution when
> inner loop has PHI node initialized from outer loop's variable.  Unfortunately,
> I lost the original C code illustrating the issue.  Now it is only triggered
> in building spec2006/416.gamess with loop nest distribution, but I failed to
> reduce a test from it.

Bah, can you re-try isolating a testcase?

> Bootstrap and test in patch set on x86_64 and AArch64, is it OK?

Ok.  Note that the renaming is a very fragile bit of code - you may run into
issues when applying it on loop nests ;)

Richard.

> Thanks,
> bin
> 2017-10-04  Bin Cheng  <bin.cheng@arm.com>
>
>         * tree-vect-loop-manip.c (rename_variables_in_bb): Rename PHI nodes
>         when copying loop nest with only one inner loop.
Bin.Cheng Oct. 10, 2017, 11:59 a.m. UTC | #2
On Mon, Oct 9, 2017 at 2:33 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Thu, Oct 5, 2017 at 3:16 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
>> Hi,
>> Function rename_variables_in_bb skips renaming PHI nodes in loop nest if the
>> outer loop has only one inner loop.  This breaks loop nest distribution when
>> inner loop has PHI node initialized from outer loop's variable.  Unfortunately,
>> I lost the original C code illustrating the issue.  Now it is only triggered
>> in building spec2006/416.gamess with loop nest distribution, but I failed to
>> reduce a test from it.
>
> Bah, can you re-try isolating a testcase?
Hi Richard,
Right, I managed a simple test with help of creduce.  Given the
simplicity of the test,
I assume previous approval still holds for this updated patch and will
apply it later.

Thanks,
bin

2017-10-10  Bin Cheng  <bin.cheng@arm.com>

    * tree-vect-loop-manip.c (rename_variables_in_bb): Rename PHI nodes
    when copying loop nest with only one inner loop.

2017-10-10  Bin Cheng  <bin.cheng@arm.com>

    * gcc.dg/tree-ssa/ldist-34.c: New test.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-34.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-34.c
new file mode 100644
index 0000000..3d68a85
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-34.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-loop-distribution" } */
+
+#define X (3.0)
+int b, c;
+double a[30000];
+int foo () {
+  for (int i = 0; i < 100; ++i) {
+    for (int j = 0; j < c; ++j)
+      if (b)
+        a[0] = b;
+    a[i * 100] = a[1] = X;
+  }
+  return 0;
+}
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 2c724a2..9fd65a7 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -117,8 +117,6 @@ rename_variables_in_bb (basic_block bb, bool rename_from_outer_loop)
 		      || single_pred (e->src) != outer_loop->header)
 		    continue;
 		}
-	      else
-		continue;
 	    }
 	}
       for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
diff mbox series

Patch

From fa3cc2014278d672db94bad5c6a606cb6888d79a Mon Sep 17 00:00:00 2001
From: Bin Cheng <binche01@e108451-lin.cambridge.arm.com>
Date: Mon, 25 Sep 2017 16:40:11 +0100
Subject: [PATCH 3/7] rename-variables-in-loop-nest.txt

---
 gcc/tree-vect-loop-manip.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 2c724a2..9fd65a7 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -117,8 +117,6 @@  rename_variables_in_bb (basic_block bb, bool rename_from_outer_loop)
 		      || single_pred (e->src) != outer_loop->header)
 		    continue;
 		}
-	      else
-		continue;
 	    }
 	}
       for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
-- 
1.9.1