]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/107865 - ICE with outlining of loops
authorRichard Biener <rguenther@suse.de>
Fri, 25 Nov 2022 07:27:42 +0000 (08:27 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 25 Nov 2022 07:27:42 +0000 (08:27 +0100)
The following makes sure to clear loops number of iterations when
outlining them as part of a SESE region as can happen with
auto-parallelization.  The referenced SSA names become stale otherwise.

PR tree-optimization/107865
* tree-cfg.cc (move_sese_region_to_fn): Free the number of
iterations of moved loops.

* gfortran.dg/graphite/pr107865.f90: New testcase.

gcc/testsuite/gfortran.dg/graphite/pr107865.f90 [new file with mode: 0644]
gcc/tree-cfg.cc

diff --git a/gcc/testsuite/gfortran.dg/graphite/pr107865.f90 b/gcc/testsuite/gfortran.dg/graphite/pr107865.f90
new file mode 100644 (file)
index 0000000..6bddb17
--- /dev/null
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options "-O1 -floop-parallelize-all -ftree-parallelize-loops=2" }
+
+      SUBROUTINE FNC (F)
+
+      IMPLICIT REAL (A-H)
+      DIMENSION F(N)
+
+      DO I = 1, 6
+         DO J = 1, 6
+            IF (J .NE. I) THEN
+               F(I) = F(I) + 1
+            END IF
+         END DO
+      END DO
+
+      RETURN
+      END
index 28175312afce59109b0255e8f756bf69e81d4ac7..0c409b435fb592f9bc6c3dd3cb33676ca8f49845 100644 (file)
@@ -7859,6 +7859,8 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
       if (bb->loop_father->header == bb)
        {
          class loop *this_loop = bb->loop_father;
+         /* Avoid the need to remap SSA names used in nb_iterations.  */
+         free_numbers_of_iterations_estimates (this_loop);
          class loop *outer = loop_outer (this_loop);
          if (outer == loop
              /* If the SESE region contains some bbs ending with