]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/65597 (ICE in build_outer_var_ref, at omp-low.c:1043)
authorJakub Jelinek <jakub@redhat.com>
Wed, 3 Jun 2015 15:31:46 +0000 (17:31 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 3 Jun 2015 15:31:46 +0000 (17:31 +0200)
Backported from mainline
2015-03-30  Jakub Jelinek  <jakub@redhat.com>

PR fortran/65597
* trans-openmp.c (gfc_trans_omp_do): For !simple simd with explicit
linear clause for the iterator set OMP_CLAUSE_LINEAR_NO_COPYIN.
For implcitly added !simple OMP_CLAUSE_LINEAR set it too.  Use step 1
instead of the original step on the new iterator - count.

* testsuite/libgomp.fortran/pr65597.f90: New test.

From-SVN: r224090

gcc/fortran/ChangeLog
gcc/fortran/trans-openmp.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.fortran/pr65597.f90 [new file with mode: 0644]

index 589f2206d5231e5def2b7f0f29ee1dd91438b59b..622fdc68425d410ad9ef8191a56a681f39080fe0 100644 (file)
@@ -1,3 +1,14 @@
+2015-06-03  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2015-03-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/65597
+       * trans-openmp.c (gfc_trans_omp_do): For !simple simd with explicit
+       linear clause for the iterator set OMP_CLAUSE_LINEAR_NO_COPYIN.
+       For implcitly added !simple OMP_CLAUSE_LINEAR set it too.  Use step 1
+       instead of the original step on the new iterator - count.
+
 2015-04-14  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/56674
index 3b0e6e9e977104d9a8d27d45a90721dc7da5bf4d..e9f4894e5eaed16068e1767d315ac8bb605a7ef3 100644 (file)
@@ -2977,6 +2977,19 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock,
          inits.safe_push (e);
        }
 
+      if (dovar_found == 2
+         && op == EXEC_OMP_SIMD
+         && collapse == 1
+         && !simple)
+       {
+         for (tmp = omp_clauses; tmp; tmp = OMP_CLAUSE_CHAIN (tmp))
+           if (OMP_CLAUSE_CODE (tmp) == OMP_CLAUSE_LINEAR
+               && OMP_CLAUSE_DECL (tmp) == dovar)
+             {
+               OMP_CLAUSE_LINEAR_NO_COPYIN (tmp) = 1;
+               break;
+             }
+       }
       if (!dovar_found)
        {
          if (op == EXEC_OMP_SIMD)
@@ -2985,6 +2998,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock,
                {
                  tmp = build_omp_clause (input_location, OMP_CLAUSE_LINEAR);
                  OMP_CLAUSE_LINEAR_STEP (tmp) = step;
+                 OMP_CLAUSE_LINEAR_NO_COPYIN (tmp) = 1;
                }
              else
                tmp = build_omp_clause (input_location, OMP_CLAUSE_LASTPRIVATE);
@@ -3052,7 +3066,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock,
          else if (collapse == 1)
            {
              tmp = build_omp_clause (input_location, OMP_CLAUSE_LINEAR);
-             OMP_CLAUSE_LINEAR_STEP (tmp) = step;
+             OMP_CLAUSE_LINEAR_STEP (tmp) = build_int_cst (type, 1);
              OMP_CLAUSE_LINEAR_NO_COPYIN (tmp) = 1;
              OMP_CLAUSE_LINEAR_NO_COPYOUT (tmp) = 1;
            }
index 20f247f1d412365bd1e53ec3280cb9b9436ccdc8..2062d3c8cb8289eca618ba836fec4733e1e64786 100644 (file)
@@ -1,6 +1,11 @@
 2015-06-03  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2015-03-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/65597
+       * testsuite/libgomp.fortran/pr65597.f90: New test.
+
        2015-03-19  Jakub Jelinek  <jakub@redhat.com>
 
        * testsuite/libgomp.c/target-10.c: New test.
diff --git a/libgomp/testsuite/libgomp.fortran/pr65597.f90 b/libgomp/testsuite/libgomp.fortran/pr65597.f90
new file mode 100644 (file)
index 0000000..c19f077
--- /dev/null
@@ -0,0 +1,21 @@
+! PR fortran/65597
+! { dg-do run }
+
+  integer :: i, a(151)
+  a(:) = 0
+  !$omp do simd
+    do i = 1, 151, 31
+      a(i) = a(i) + 1
+    end do
+  !$omp do simd linear (i: 31)
+    do i = 1, 151, 31
+      a(i) = a(i) + 1
+    end do
+  do i = 1, 151
+    if (mod (i, 31) .eq. 1) then
+      if (a(i) .ne. 2) call abort
+    else
+      if (a(i) .ne. 0) call abort
+    end if
+  end do
+end