[LLVM] Fix Maintainers.md formatting (NFC)
[llvm-project.git] / flang / test / Lower / OpenACC / acc-atomic-update-hlfir.f90
blob3d5374aff41a075060321fe447ee1aa22665486c
1 ! This test checks lowering of atomic and atomic update constructs with HLFIR
2 ! RUN: bbc -hlfir -fopenacc -emit-hlfir %s -o - | FileCheck %s
3 ! RUN: %flang_fc1 -emit-hlfir -fopenacc %s -o - | FileCheck %s
5 !CHECK-LABEL: @_QPsb
6 subroutine sb
7 !CHECK: %[[W_REF:.*]] = fir.alloca i32 {bindc_name = "w", uniq_name = "_QFsbEw"}
8 !CHECK: %[[W_DECL:.*]]:2 = hlfir.declare %[[W_REF]] {uniq_name = "_QFsbEw"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
9 !CHECK: %[[X_REF:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFsbEx"}
10 !CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[X_REF]] {uniq_name = "_QFsbEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
11 !CHECK: %[[Y_REF:.*]] = fir.alloca i32 {bindc_name = "y", uniq_name = "_QFsbEy"}
12 !CHECK: %[[Y_DECL:.*]]:2 = hlfir.declare %[[Y_REF]] {uniq_name = "_QFsbEy"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
13 !CHECK: %[[Z_REF:.*]] = fir.alloca i32 {bindc_name = "z", uniq_name = "_QFsbEz"}
14 !CHECK: %[[Z_DECL:.*]]:2 = hlfir.declare %[[Z_REF]] {uniq_name = "_QFsbEz"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
15 integer :: w, x, y, z
17 !CHECK: %[[Y_VAL:.*]] = fir.load %[[Y_DECL]]#0 : !fir.ref<i32>
18 !CHECK: acc.atomic.update %[[X_DECL]]#1 : !fir.ref<i32> {
19 !CHECK: ^bb0(%[[ARG_X:.*]]: i32):
20 !CHECK: %[[X_UPDATE_VAL:.*]] = arith.addi %[[ARG_X]], %[[Y_VAL]] : i32
21 !CHECK: acc.yield %[[X_UPDATE_VAL]] : i32
22 !CHECK: }
23 !$acc atomic update
24 x = x + y
26 !CHECK: %[[Y_VAL:.*]] = fir.load %[[Y_DECL]]#0 : !fir.ref<i32>
27 !CHECK: acc.atomic.update %[[X_DECL]]#1 : !fir.ref<i32> {
28 !CHECK: ^bb0(%[[ARG_X:.*]]: i32):
29 !CHECK: %[[X_UPDATE_VAL:.*]] = arith.ori %[[ARG_X]], %[[Y_VAL]] : i32
30 !CHECK: acc.yield %[[X_UPDATE_VAL]] : i32
31 !CHECK: }
32 !$acc atomic update
33 x = ior(x,y)
35 !CHECK: %[[W_VAL:.*]] = fir.load %[[W_DECL]]#0 : !fir.ref<i32>
36 !CHECK: %[[X_VAL:.*]] = fir.load %[[X_DECL]]#0 : !fir.ref<i32>
37 !CHECK: %[[Y_VAL:.*]] = fir.load %[[Y_DECL]]#0 : !fir.ref<i32>
38 !CHECK: acc.atomic.update %[[Z_DECL]]#1 : !fir.ref<i32> {
39 !CHECK: ^bb0(%[[ARG_Z:.*]]: i32):
40 !CHECK: %[[WX_CMP:.*]] = arith.cmpi slt, %[[W_VAL]], %[[X_VAL]] : i32
41 !CHECK: %[[WX_MIN:.*]] = arith.select %[[WX_CMP]], %[[W_VAL]], %[[X_VAL]] : i32
42 !CHECK: %[[WXY_CMP:.*]] = arith.cmpi slt, %[[WX_MIN]], %[[Y_VAL]] : i32
43 !CHECK: %[[WXY_MIN:.*]] = arith.select %[[WXY_CMP]], %[[WX_MIN]], %[[Y_VAL]] : i32
44 !CHECK: %[[WXYZ_CMP:.*]] = arith.cmpi slt, %[[WXY_MIN]], %[[ARG_Z]] : i32
45 !CHECK: %[[WXYZ_MIN:.*]] = arith.select %[[WXYZ_CMP]], %[[WXY_MIN]], %[[ARG_Z]] : i32
46 !CHECK: acc.yield %[[WXYZ_MIN]] : i32
47 !CHECK: }
48 !$acc atomic update
49 z = min(w,x,y,z)
51 !CHECK: return
52 end subroutine