[flang-commits] [flang] [NFC][flang][OpenMP] `do concurrent` to device mapping lit tests (PR #155992)

Pranav Bhandarkar via flang-commits flang-commits at lists.llvm.org
Sat Sep 13 21:31:56 PDT 2025


================
@@ -0,0 +1,29 @@
+! Verifies that proper `omp.map.bounds` ops are emitted when an allocatable is
+! implicitly mapped by a `do concurrent` loop.
+
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=device %s -o - \
+! RUN:   | FileCheck %s
+program main
+   implicit none
+
+   integer,parameter :: n = 1000000
+   real, allocatable, dimension(:) :: y
+   integer :: i
+
+   allocate(y(1:n))
+
+   do concurrent(i=1:n)
+       y(i) = 42
+   end do
+
+   deallocate(y)
+end program main
+
+! CHECK: %[[Y_DECL:.*]]:2 = hlfir.declare %{{.*}} {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFEy"}
+! CHECK: %[[Y_VAL:.*]] = fir.load %[[Y_DECL]]#0
+! CHECK: %[[Y_DIM0:.*]]:3 = fir.box_dims %[[Y_VAL]], %{{c0_.*}}
----------------
bhandarkar-pranav wrote:

< NIT > I think this test would be more robust if you captured the names of the output values of ops that defined the constants and then matched them to make sure you are getting the 0th dim out of `fir.box_dims` or subtracting 1 in an `arith.subi` op.
```
%[[C0:.*]] = arith.constant 0 : i32
%[[C1:.*]] = arith.constant 1 : i32
```

Same thing in map_shape_info.f90 below.

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


More information about the flang-commits mailing list