xref: /llvm-project/flang/test/Integration/OpenMP/atomic-capture-complex.f90 (revision 6ce4b6dd070d9444c2a6761554d21495ba17213c)
1!===----------------------------------------------------------------------===!
2! This directory can be used to add Integration tests involving multiple
3! stages of the compiler (for eg. from Fortran to LLVM IR). It should not
4! contain executable tests. We should only add tests here sparingly and only
5! if there is no other way to test. Repeat this message in each test that is
6! added to this directory and sub-directories.
7!===----------------------------------------------------------------------===!
8
9!RUN: %if x86-registered-target %{ %flang_fc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fopenmp %s -o - | FileCheck --check-prefixes=CHECK,X86 %s %}
10!RUN: %if aarch64-registerd-target %{ %flang_fc1 -triple aarch64-unknown-linux-gnu -emit-llvm -fopenmp %s -o - | FileCheck --check-prefixes=CHECK,AARCH64 %s %}
11
12!CHECK: %[[X_NEW_VAL:.*]] = alloca { float, float }, align 8
13!CHECK: %[[VAL_1:.*]] = alloca { float, float }, i64 1, align 8
14!CHECK: %[[ORIG_VAL:.*]] = alloca { float, float }, i64 1, align 8
15!CHECK: store { float, float } { float 2.000000e+00, float 2.000000e+00 }, ptr %[[ORIG_VAL]], align 4
16!CHECK: br label %entry
17
18!CHECK: entry:
19!CHECK: %[[ATOMIC_TEMP_LOAD:.*]] = alloca { float, float }, align 8
20!CHECK: call void @__atomic_load(i64 8, ptr %[[ORIG_VAL]], ptr %[[ATOMIC_TEMP_LOAD]], i32 0)
21!CHECK: %[[PHI_NODE_ENTRY_1:.*]] = load { float, float }, ptr %[[ATOMIC_TEMP_LOAD]], align 8
22!CHECK: br label %.atomic.cont
23
24!CHECK: .atomic.cont
25!CHECK: %[[VAL_4:.*]] = phi { float, float } [ %[[PHI_NODE_ENTRY_1]], %entry ], [ %{{.*}}, %.atomic.cont ]
26!CHECK: %[[VAL_5:.*]] = extractvalue { float, float } %[[VAL_4]], 0
27!CHECK: %[[VAL_6:.*]] = extractvalue { float, float } %[[VAL_4]], 1
28!CHECK: %[[VAL_7:.*]] = fadd contract float %[[VAL_5]], 1.000000e+00
29!CHECK: %[[VAL_8:.*]] = fadd contract float %[[VAL_6]], 1.000000e+00
30!CHECK: %[[VAL_9:.*]] = insertvalue { float, float } undef, float %[[VAL_7]], 0
31!CHECK: %[[VAL_10:.*]] = insertvalue { float, float } %[[VAL_9]], float %[[VAL_8]], 1
32!CHECK: store { float, float } %[[VAL_10]], ptr %[[X_NEW_VAL]], align 4
33!CHECK: %[[VAL_11:.*]] = call i1 @__atomic_compare_exchange(i64 8, ptr %[[ORIG_VAL]], ptr %[[ATOMIC_TEMP_LOAD]], ptr %[[X_NEW_VAL]],
34!i32 2, i32 2)
35!CHECK: %[[VAL_12:.*]] = load { float, float }, ptr %[[ATOMIC_TEMP_LOAD]], align 4
36!CHECK: br i1 %[[VAL_11]], label %.atomic.exit, label %.atomic.cont
37
38!CHECK:   .atomic.exit
39!AARCH64: %[[LCSSA:.*]] = phi { float, float } [ %[[VAL_10]], %.atomic.cont ]
40!AARCH64: store { float, float } %[[LCSSA]], ptr %[[VAL_1]], align 4
41!X86:     store { float, float } %[[VAL_10]], ptr %[[VAL_1]], align 4
42
43program main
44      complex*8 ia, ib
45      ia = (2, 2)
46      !$omp atomic capture
47        ia = ia + (1, 1)
48        ib = ia
49      !$omp end atomic
50end program
51