[flang-commits] [flang] c9f6b2e - [flang][test][NFC] Add OpenMP test for mismatched loop bound types (#221097)

via flang-commits flang-commits at lists.llvm.org
Tue Sep 15 12:09:53 PDT 2026


Author: Gheorghe-Teodor Bercea
Date: 2026-09-15T15:09:47-04:00
New Revision: c9f6b2e48b9c021d44cdfd70b49ce6abb2fcbd26

URL: https://github.com/llvm/llvm-project/commit/c9f6b2e48b9c021d44cdfd70b49ce6abb2fcbd26
DIFF: https://github.com/llvm/llvm-project/commit/c9f6b2e48b9c021d44cdfd70b49ce6abb2fcbd26.diff

LOG: [flang][test][NFC] Add OpenMP test for mismatched loop bound types (#221097)

Adds a regression test that lowering succeeds when an OpenMP loop mixes
bound types: the loop trip count comes from an integer(kind=INT64)
module
variable while the lower bound and step are i32 literals, so both are
converted to i64 before being passed through host_eval.

Added: 
    flang/test/Lower/OpenMP/mismatched-bound-types.f90

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/flang/test/Lower/OpenMP/mismatched-bound-types.f90 b/flang/test/Lower/OpenMP/mismatched-bound-types.f90
new file mode 100644
index 0000000000000..8b24b34cb55b6
--- /dev/null
+++ b/flang/test/Lower/OpenMP/mismatched-bound-types.f90
@@ -0,0 +1,35 @@
+! RUN: %flang_fc1 -fopenmp -emit-fir %s -o - | FileCheck %s
+
+! Check that this testcase is lowered to FIR successfully.
+
+! CHECK: %[[ONE:.*]] = arith.constant 1 : i32
+! CHECK: %[[DECL_N:.*]] = fir.declare %{{.*}} {uniq_name = "_QMtestEn"} : (!fir.ref<i64>) -> !fir.ref<i64>
+! CHECK: %[[HOST_N:.*]] = fir.load %[[DECL_N]] : !fir.ref<i64>
+! CHECK: %[[HOST_LB:.*]] = fir.convert %[[ONE]] : (i32) -> i64
+! CHECK: %[[HOST_STEP:.*]] = fir.convert %[[ONE]] : (i32) -> i64
+! CHECK:      omp.target
+! CHECK-SAME: host_eval(%[[HOST_LB]] -> %[[LB:[[:alnum:]]+]], %[[HOST_N]] -> %[[UB:[[:alnum:]]+]], %[[HOST_STEP]] -> %[[STEP:[[:alnum:]]+]] : i64, i64, i64)
+! CHECK:      omp.teams
+! CHECK:      omp.parallel
+! CHECK:      omp.distribute
+! CHECK-NEXT: omp.wsloop
+! CHECK-NEXT: omp.loop_nest ({{.*}}) : i64 = (%[[LB]]) to (%[[UB]]) inclusive step (%[[STEP]])
+
+module Test
+    use, intrinsic :: ISO_Fortran_env, only: REAL64,INT64
+    implicit none
+    integer(kind=INT64) :: N
+    real(kind=REAL64), allocatable :: A(:)
+
+    contains
+        subroutine init_arrays(initA)
+            implicit none
+            real(kind=REAL64), intent(in) :: initA
+            integer(kind=INT64) :: i
+            !$omp target teams distribute parallel do
+            do i = 1, N
+                A(i) = initA
+            end do
+        end subroutine init_arrays
+
+end module Test


        


More information about the flang-commits mailing list