[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / mlir / test / Target / LLVMIR / openmp-reduction-typed-pointers.mlir
blob64d345fb1f1d8f87977f568e2a7408b3a7108b58
1 // RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
3 // Only check the overall shape of the code and the presence of relevant
4 // runtime calls. Actual IR checking is done at the OpenMPIRBuilder level.
6 omp.reduction.declare @add_f32 : f32
7 init {
8 ^bb0(%arg: f32):
9   %0 = llvm.mlir.constant(0.0 : f32) : f32
10   omp.yield (%0 : f32)
12 combiner {
13 ^bb1(%arg0: f32, %arg1: f32):
14   %1 = llvm.fadd %arg0, %arg1 : f32
15   omp.yield (%1 : f32)
17 atomic {
18 ^bb2(%arg2: !llvm.ptr<f32>, %arg3: !llvm.ptr<f32>):
19   %2 = llvm.load %arg3 : !llvm.ptr<f32>
20   llvm.atomicrmw fadd %arg2, %2 monotonic : !llvm.ptr<f32>, f32
21   omp.yield
24 // CHECK-LABEL: @simple_reduction
25 llvm.func @simple_reduction(%lb : i64, %ub : i64, %step : i64) {
26   %c1 = llvm.mlir.constant(1 : i32) : i32
27   %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr<f32>
28   omp.parallel {
29     omp.wsloop reduction(@add_f32 -> %0 : !llvm.ptr<f32>)
30     for (%iv) : i64 = (%lb) to (%ub) step (%step) {
31       %1 = llvm.mlir.constant(2.0 : f32) : f32
32       omp.reduction %1, %0 : f32, !llvm.ptr<f32>
33       omp.yield
34     }
35     omp.terminator
36   }
37   llvm.return
40 // Call to the outlined function.
41 // CHECK: call void {{.*}} @__kmpc_fork_call
42 // CHECK-SAME: @[[OUTLINED:[A-Za-z_.][A-Za-z0-9_.]*]]
44 // Outlined function.
45 // CHECK: define internal void @[[OUTLINED]]
47 // Private reduction variable and its initialization.
48 // CHECK: %[[PRIVATE:.+]] = alloca float
49 // CHECK: store float 0.000000e+00, ptr %[[PRIVATE]]
51 // Call to the reduction function.
52 // CHECK: call i32 @__kmpc_reduce
53 // CHECK-SAME: @[[REDFUNC:[A-Za-z_.][A-Za-z0-9_.]*]]
55 // Atomic reduction.
56 // CHECK: %[[PARTIAL:.+]] = load float, ptr %[[PRIVATE]]
57 // CHECK: atomicrmw fadd ptr %{{.*}}, float %[[PARTIAL]]
59 // Non-atomic reduction:
60 // CHECK: fadd float
61 // CHECK: call void @__kmpc_end_reduce
62 // CHECK: br label %[[FINALIZE:.+]]
64 // CHECK: [[FINALIZE]]:
65 // CHECK: call void @__kmpc_barrier
67 // Update of the private variable using the reduction region
68 // (the body block currently comes after all the other blocks).
69 // CHECK: %[[PARTIAL:.+]] = load float, ptr %[[PRIVATE]]
70 // CHECK: %[[UPDATED:.+]] = fadd float %[[PARTIAL]], 2.000000e+00
71 // CHECK: store float %[[UPDATED]], ptr %[[PRIVATE]]
73 // Reduction function.
74 // CHECK: define internal void @[[REDFUNC]]
75 // CHECK: fadd float