re PR middle-end/70643 (broken openacc reduction inside a fortran module)
authorCesar Philippidis <cesar@codesourcery.com>
Thu, 14 Apr 2016 13:44:17 +0000 (06:44 -0700)
committerCesar Philippidis <cesar@gcc.gnu.org>
Thu, 14 Apr 2016 13:44:17 +0000 (06:44 -0700)
PR middle-end/70643

gcc/
* omp-low.c (lower_oacc_reductions): Check for TREE_CONSTANT
when building a mem ref for the incoming reduction variable.

libgomp/
* testsuite/libgomp.oacc-fortran/pr70643.f90: New test.

From-SVN: r234973

gcc/ChangeLog
gcc/omp-low.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.oacc-fortran/pr70643.f90 [new file with mode: 0644]

index 19575f0fc79d0ff02ed427e4e23b62e0e98d0eac..ca2a9a746008c5a19f71cc3d51ffee8430b4d801 100644 (file)
@@ -1,3 +1,9 @@
+2016-04-14  Cesar Philippidis  <cesar@codesourcery.com>
+
+       PR middle-end/70643
+       * omp-low.c (lower_oacc_reductions): Check for TREE_CONSTANT
+       when building a mem ref for the incoming reduction variable.
+
 2016-04-14  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/70614
index 7335abc6396f4a6a91c29389143345f1560f5b18..aa3721edc9da9adc4a3bf609224c796bf2426376 100644 (file)
@@ -5691,7 +5691,7 @@ lower_oacc_reductions (location_t loc, tree clauses, tree level, bool inner,
            v3 = build_simple_mem_ref (v3);
            outgoing = build_simple_mem_ref (outgoing);
 
-           if (TREE_CODE (incoming) != INTEGER_CST)
+           if (!TREE_CONSTANT (incoming))
              incoming = build_simple_mem_ref (incoming);
          }
        else
index d4411c0f55702b2a87ca668593d9df83964301e1..89ee866ac4c7f1ae07df0b79c64f3bd67514979a 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-14  Cesar Philippidis  <cesar@codesourcery.com>
+
+       PR middle-end/70643
+       * testsuite/libgomp.oacc-fortran/pr70643.f90: New test.
+
 2016-04-13  Cesar Philippidis  <cesar@codesourcery.com>
 
        PR testsuite/68242
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/pr70643.f90 b/libgomp/testsuite/libgomp.oacc-fortran/pr70643.f90
new file mode 100644 (file)
index 0000000..7c2e5ee
--- /dev/null
@@ -0,0 +1,51 @@
+MODULE reduction_test
+
+CONTAINS
+
+SUBROUTINE reduction_kernel(x_min,x_max,y_min,y_max,arr,sum)
+
+  IMPLICIT NONE
+
+  INTEGER      :: x_min,x_max,y_min,y_max
+  REAL(KIND=8), DIMENSION(x_min-2:x_max+2,y_min-2:y_max+2) :: arr
+  REAL(KIND=8) :: sum
+
+  INTEGER      :: j,k
+
+!$ACC DATA PRESENT(arr) COPY(sum)
+!$ACC PARALLEL LOOP REDUCTION(+ : sum)
+  DO k=y_min,y_max
+    DO j=x_min,x_max
+      sum=sum+arr(j,k)
+    ENDDO
+  ENDDO
+!$ACC END PARALLEL LOOP
+!$ACC END DATA
+END SUBROUTINE reduction_kernel
+
+END MODULE reduction_test
+
+program main
+    use reduction_test
+
+    integer :: x_min,x_max,y_min,y_max
+    real(kind=8), dimension(1:10,1:10) :: arr
+    real(kind=8) :: sum
+
+    x_min = 1
+    x_max = 2
+    y_min = 1
+    y_max = 2
+
+    arr(:,:) = 1.0
+
+    sum = 0.0
+
+    !$acc data copy(arr)
+
+    call reduction_kernel(x_min,x_max,y_min,y_max,arr,sum)
+
+    !$acc end data
+
+    if (sum .ne. 4.0) call abort
+end program