public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/101173 - fix interchange dependence checking
@ 2021-06-23 13:16 Richard Biener
  2021-06-23 23:57 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Biener @ 2021-06-23 13:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: bin.cheng

This adjusts the loop interchange dependence checking to disallow
an outer loop dependence distance of zero.

Bootstrapped and tested on x86_64-unknown-linux-gnu, OK?

Thanks,
Richard.

2021-06-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/101173
	* gimple-loop-interchange.cc
	(tree_loop_interchange::valid_data_dependences): Disallow outer
	loop dependence distance of zero.

	* gcc.dg/torture/pr101173.c: New testcase.
---
 gcc/gimple-loop-interchange.cc          |  4 ++--
 gcc/testsuite/gcc.dg/torture/pr101173.c | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/pr101173.c

diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc
index 80f749b6071..43045c5455e 100644
--- a/gcc/gimple-loop-interchange.cc
+++ b/gcc/gimple-loop-interchange.cc
@@ -1043,8 +1043,8 @@ tree_loop_interchange::valid_data_dependences (unsigned i_idx, unsigned o_idx,
 	    continue;
 
 	  /* Be conservative, skip case if either direction at i_idx/o_idx
-	     levels is not '=' or '<'.  */
-	  if (dist_vect[i_idx] < 0 || dist_vect[o_idx] < 0)
+	     levels is not '=' (for the inner loop) or '<'.  */
+	  if (dist_vect[i_idx] < 0 || dist_vect[o_idx] <= 0)
 	    return false;
 	}
     }
diff --git a/gcc/testsuite/gcc.dg/torture/pr101173.c b/gcc/testsuite/gcc.dg/torture/pr101173.c
new file mode 100644
index 00000000000..0c9090d6686
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101173.c
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+/* { dg-additional-options "-floop-interchange" } */
+
+int a[6][9];
+int main()
+{
+  a[1][3] = 8;
+  for (int b = 1; b <= 5; b++)
+    for (int d = 0; d <= 5; d++)
+#pragma GCC unroll 0
+      for (int c = 0; c <= 5; c++)
+        a[b][c] = a[b][c + 2] & 216;
+  for (int e = 0; e < 6; e++)
+    for (int f = 0; f < 9; f++)
+      if (a[e][f] != 0)
+        __builtin_abort ();
+  return 0;
+}
-- 
2.26.2

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] tree-optimization/101173 - fix interchange dependence checking
  2021-06-23 13:16 [PATCH] tree-optimization/101173 - fix interchange dependence checking Richard Biener
@ 2021-06-23 23:57 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2021-06-23 23:57 UTC (permalink / raw)
  To: Richard Biener, gcc-patches; +Cc: bin.cheng



On 6/23/2021 7:16 AM, Richard Biener wrote:
> This adjusts the loop interchange dependence checking to disallow
> an outer loop dependence distance of zero.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, OK?
>
> Thanks,
> Richard.
>
> 2021-06-23  Richard Biener  <rguenther@suse.de>
>
> 	PR tree-optimization/101173
> 	* gimple-loop-interchange.cc
> 	(tree_loop_interchange::valid_data_dependences): Disallow outer
> 	loop dependence distance of zero.
>
> 	* gcc.dg/torture/pr101173.c: New testcase.
OK
jeff


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-23 23:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 13:16 [PATCH] tree-optimization/101173 - fix interchange dependence checking Richard Biener
2021-06-23 23:57 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).