Handle equal-argument loop exit phi in expand_omp_for_static_chunk
authorTom de Vries <tom@codesourcery.com>
Wed, 19 Jul 2017 06:25:40 +0000 (06:25 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Wed, 19 Jul 2017 06:25:40 +0000 (06:25 +0000)
2017-07-18  Tom de Vries  <tom@codesourcery.com>

PR middle-end/81464
* omp-expand.c (expand_omp_for_static_chunk): Handle equal-argument loop
exit phi.

* gfortran.dg/pr81464.f90: New test.

From-SVN: r250335

gcc/ChangeLog
gcc/omp-expand.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr81464.f90 [new file with mode: 0644]

index ef0e78810732ae9d9aa9af21cc8ebda37537f157..54e78a62dbfd65c186033e40e101b3f861928366 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-18  Tom de Vries  <tom@codesourcery.com>
+
+       PR middle-end/81464
+       * omp-expand.c (expand_omp_for_static_chunk): Handle equal-argument loop
+       exit phi.
+
 2017-07-18  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/81471
index 929c53078d5c0840214a04b83fe4e45e74d0cd3f..d6755cd71ee78e1f0bbfff63da920b0ed63d4eeb 100644 (file)
@@ -4206,6 +4206,10 @@ expand_omp_for_static_chunk (struct omp_region *region,
          source_location locus;
 
          phi = psi.phi ();
+         if (operand_equal_p (gimple_phi_arg_def (phi, 0),
+                              redirect_edge_var_map_def (vm), 0))
+           continue;
+
          t = gimple_phi_result (phi);
          gcc_assert (t == redirect_edge_var_map_result (vm));
 
index 1929d15be82ef8df052262ddc97b2c3381cecca2..4687e45d36ceffab7507fb508622d9de6697fd69 100644 (file)
@@ -1,3 +1,8 @@
+2017-07-18  Tom de Vries  <tom@codesourcery.com>
+
+       PR middle-end/81464
+       * gfortran.dg/pr81464.f90: New test.
+
 2017-07-18  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/81471
diff --git a/gcc/testsuite/gfortran.dg/pr81464.f90 b/gcc/testsuite/gfortran.dg/pr81464.f90
new file mode 100644 (file)
index 0000000..425cae9
--- /dev/null
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! { dg-options "--param parloops-chunk-size=2 -ftree-parallelize-loops=2 -O1" }
+
+program main
+  implicit none
+  real, dimension(:,:),allocatable :: a, b, c
+  real :: sm
+
+  allocate (a(2,2), b(2,2), c(2,2))
+
+  call random_number(a)
+  call random_number(b)
+
+  c = matmul(a,b)
+  sm = sum(c)
+
+  deallocate(a,b,c)
+
+end program main