* [PATCH] tree-optimization/106533 - loop distribution of inner loop of nest
@ 2022-08-05 10:08 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-08-05 10:08 UTC (permalink / raw)
To: gcc-patches
Loop distribution currently gives up if the outer loop of a loop
nest it analyzes contains a stmt with side-effects instead of
continuing to analyze the innermost loop. The following fixes that
by continuing anyway.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/106533
* tree-loop-distribution.cc (loop_distribution::execute): Continue
analyzing the inner loops when find_seed_stmts_for_distribution
fails.
* gcc.dg/tree-ssa/ldist-39.c: New testcase.
---
gcc/testsuite/gcc.dg/tree-ssa/ldist-39.c | 16 ++++++++++++++++
gcc/tree-loop-distribution.cc | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ldist-39.c
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-39.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-39.c
new file mode 100644
index 00000000000..3ef72864d96
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-39.c
@@ -0,0 +1,16 @@
+/* PR/106533 */
+/* { dg-options "-O2 -fdump-tree-ldist-optimized" } */
+
+void bar (int *a, int * __restrict b)
+{
+ for (int k = 0; k < 10; k++)
+ {
+ for (int j = 0; j < 100000; ++j)
+ a[j] = b[j];
+ __builtin_printf ("Foo!");
+ }
+}
+
+/* The stmt with side-effects in the outer loop should not prevent
+ distribution of the inner loop of the loop nest. */
+/* { dg-final { scan-tree-dump "optimized: Loop . distributed: split to 0 loops and 1 library calls" "ldist" } } */
diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc
index 0ee441c077d..e1948fb452a 100644
--- a/gcc/tree-loop-distribution.cc
+++ b/gcc/tree-loop-distribution.cc
@@ -3829,7 +3829,7 @@ loop_distribution::execute (function *fun)
{
auto_vec<gimple *> work_list;
if (!find_seed_stmts_for_distribution (loop, &work_list))
- break;
+ continue;
const char *str = loop->inner ? " nest" : "";
dump_user_location_t loc = find_loop_location (loop);
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-05 10:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-05 10:08 [PATCH] tree-optimization/106533 - loop distribution of inner loop of nest Richard Biener
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).