[flang-commits] [flang] [Flang][OpenMP] Add semantic support for Loop Sequences and OpenMP loop fuse (PR #161213)

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Wed Oct 1 05:07:07 PDT 2025


================
@@ -0,0 +1,95 @@
+! Testing the Semantics of loop sequences combined with 
+! nested Loop Transformation Constructs
+
+!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60
+
+subroutine loop_transformation_construct1
+  implicit none
+
+  !$omp do
+  !ERROR: The FUSE construct requires the END FUSE directive
+  !$omp fuse 
+end subroutine
+
+subroutine loop_transformation_construct2
+  implicit none
+
+  !$omp do
+  !ERROR: A DO loop must follow the FUSE directive
+  !$omp fuse 
+  !ERROR: The END FUSE directive must follow the DO loop associated with the loop construct
+  !$omp end fuse
+end subroutine
+
+subroutine loop_transformation_construct3
+  implicit none
+  integer :: i = 5
+  integer :: y
+  integer :: v(i)
+
+  !$omp do
+  !$omp fuse
+  do x = 1, i
+    v(x) = x(x) * 2
+  end do
+  do x = 1, i
+    v(x) = x(x) * 2
+  end do
+  !$omp end fuse
+  !$omp end do
+  !ERROR: The END FUSE directive must follow the DO loop associated with the loop construct
+  !$omp end fuse
+end subroutine
+
+subroutine loop_transformation_construct4
+  implicit none
+  integer :: i = 5
+  integer :: y
+  integer :: v(i)
+
+  !$omp do
+  do x = 1, i
+    v(x) = x(x) * 2
+  end do
+  !ERROR: A DO loop must follow the FUSE directive
+  !$omp fuse
+  !ERROR: The END FUSE directive must follow the DO loop associated with the loop construct
+  !$omp end fuse
+end subroutine
+
+subroutine loop_transformation_construct5
+  implicit none
+  integer :: i = 5
+  integer :: y
+  integer :: v(i)
+
+  !$omp do
+  !ERROR: If a loop construct has been fully unrolled, it cannot then be further transformed
+  !$omp fuse
+  !$omp unroll full
+  do x = 1, i
+    v(x) = x(x) * 2
+  end do
+  do x = 1, i
+    v(x) = x(x) * 2
+  end do
+  !$omp end fuse
+end subroutine
+
+subroutine loop_transformation_construct6
+  implicit none
+  integer :: i = 5
+  integer :: y
+  integer :: v(i)
+
+  !$omp do
+  !$omp fuse
+  !$omp unroll partial(2)
----------------
Meinersbur wrote:

```suggestion
  !ERROR: Cannot unroll a loops sequence, must be fused first
  !$omp unroll partial(2)
```

https://github.com/llvm/llvm-project/pull/161213


More information about the flang-commits mailing list