Skip to content

Commit 6f9e688

Browse files
authored
[flang][OpenMP] Fix reduction init region block management (llvm#122079)
Replaces llvm#121886 Fixes llvm#120254 (hopefully 🤞) ## Problem Consider the following example: ```fortran program test real :: x(1) integer :: i !$omp parallel do reduction(+:x) do i = 1,1 x = 1 end do !$omp end parallel do end program ``` The HLFIR+OMP IR for this example looks like this: ```mlir func.func @_QQmain() { ... omp.parallel { %5 = fir.embox %4#0(%3) : (!fir.ref<!fir.array<1xf32>>, !fir.shape<1>) -> !fir.box<!fir.array<1xf32>> %6 = fir.alloca !fir.box<!fir.array<1xf32>> ... omp.wsloop private(@_QFEi_private_ref_i32 %1#0 -> %arg0 : !fir.ref<i32>) reduction(byref @add_reduction_byref_box_1xf32 %6 -> %arg1 : !fir.ref<!fir.box<!fir.array<1xf32>>>) { omp.loop_nest (%arg2) : i32 = (%c1_i32) to (%c1_i32_0) inclusive step (%c1_i32_1) { ... omp.yield } } omp.terminator } return } ``` The problem addressed by this PR is related to: the `alloca` in the `omp.parallel` region + the related `reduction` clause on the `omp.wsloop` op. When we try translate the reduction from MLIR to LLVM, we have to choose an `alloca` insertion point. This happens in `convertOmpWsloop` where at entry to that function, this is what the LLVM module looks like: ```llvm define void @_QQmain() { %tid.addr = alloca i32, align 4 ... entry: %omp_global_thread_num = call i32 @__kmpc_global_thread_num(ptr @1) br label %omp.par.entry omp.par.entry: %tid.addr.local = alloca i32, align 4 ... br label %omp.par.region omp.par.region: br label %omp.par.region1 omp.par.region1: ... %5 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8 ``` Now, when we choose an `alloca` insertion point for the reduction, this is the chosen block `omp.par.entry` (without the changes in this PR). The problem is that the allocation needed for the reduction needs to reference the `%5` SSA value. This results in inserting allocations in `omp.par.entry` that reference allocations in a later block `omp.par.region1` which causes the `Instruction does not dominate all uses!` error. ## Possible solution - take 2: This PR contains a more localized solution than llvm#121886. It makes sure that on entry to `initReductionVars`, the IR builder is at a point where we can starting inserting initialization region; to make things cleaner, we still split the builder insertion point to a dedicated `omp.reduction.init`. This way we avoid splitting after the latest allocation block; which is what causing the issue.
1 parent de12836 commit 6f9e688

9 files changed

+110
-46
lines changed

flang/test/Integration/OpenMP/parallel-private-reduction-worstcase.f90

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ subroutine worst_case(a, b, c, d)
9696

9797
! CHECK: omp.region.cont13: ; preds = %omp.private.copy16
9898
! CHECK-NEXT: %{{.*}} = phi ptr
99+
! CHECK-NEXT: br label %omp.par.region
100+
101+
! CHECK: omp.par.region: ; preds = %omp.region.cont13
99102
! CHECK-NEXT: br label %omp.reduction.init
100103

101-
! CHECK: omp.reduction.init: ; preds = %omp.region.cont13
104+
! CHECK: omp.reduction.init: ; preds = %omp.par.region
102105
! [deffered stores for results of reduction alloc regions]
103106
! CHECK: br label %[[VAL_96:.*]]
104107

@@ -132,12 +135,9 @@ subroutine worst_case(a, b, c, d)
132135

133136
! CHECK: omp.region.cont21: ; preds = %omp.reduction.neutral25
134137
! CHECK-NEXT: %{{.*}} = phi ptr
135-
! CHECK-NEXT: br label %omp.par.region
136-
137-
! CHECK: omp.par.region: ; preds = %omp.region.cont21
138138
! CHECK-NEXT: br label %omp.par.region27
139139

140-
! CHECK: omp.par.region27: ; preds = %omp.par.region
140+
! CHECK: omp.par.region27: ; preds = %omp.region.cont21
141141
! [call SUM runtime function]
142142
! [if (sum(a) == 1)]
143143
! CHECK: br i1 %{{.*}}, label %omp.par.region28, label %omp.par.region29

flang/test/Lower/OpenMP/parallel-reduction-mixed.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ end subroutine proc
2727
!CHECK: %[[F_priv:.*]] = alloca ptr
2828
!CHECK: %[[I_priv:.*]] = alloca i32
2929

30+
!CHECK: omp.par.region:
31+
3032
!CHECK: omp.reduction.init:
3133
!CHECK: store ptr %{{.*}}, ptr %[[F_priv]]
3234
!CHECK: store i32 0, ptr %[[I_priv]]
33-
34-
!CHECK: omp.par.region:
3535
!CHECK: br label %[[MALLOC_BB:.*]]
3636

3737
!CHECK: [[MALLOC_BB]]:

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,11 @@ mapInitializationArgs(T loop, LLVM::ModuleTranslation &moduleTranslation,
10251025
}
10261026
}
10271027

1028+
/// Inline reductions' `init` regions. This functions assumes that the
1029+
/// `builder`'s insertion point is where the user wants the `init` regions to be
1030+
/// inlined; i.e. it does not try to find a proper insertion location for the
1031+
/// `init` regions. It also leaves the `builder's insertions point in a state
1032+
/// where the user can continue the code-gen directly afterwards.
10281033
template <typename OP>
10291034
static LogicalResult
10301035
initReductionVars(OP op, ArrayRef<BlockArgument> reductionArgs,
@@ -1039,9 +1044,6 @@ initReductionVars(OP op, ArrayRef<BlockArgument> reductionArgs,
10391044
if (op.getNumReductionVars() == 0)
10401045
return success();
10411046

1042-
llvm::IRBuilderBase::InsertPointGuard guard(builder);
1043-
1044-
builder.SetInsertPoint(latestAllocaBlock->getTerminator());
10451047
llvm::BasicBlock *initBlock = splitBB(builder, true, "omp.reduction.init");
10461048
auto allocaIP = llvm::IRBuilderBase::InsertPoint(
10471049
latestAllocaBlock, latestAllocaBlock->getTerminator()->getIterator());
@@ -1061,7 +1063,10 @@ initReductionVars(OP op, ArrayRef<BlockArgument> reductionArgs,
10611063
}
10621064
}
10631065

1064-
builder.SetInsertPoint(&*initBlock->getFirstNonPHIOrDbgOrAlloca());
1066+
if (initBlock->empty() || initBlock->getTerminator() == nullptr)
1067+
builder.SetInsertPoint(initBlock);
1068+
else
1069+
builder.SetInsertPoint(initBlock->getTerminator());
10651070

10661071
// store result of the alloc region to the allocated pointer to the real
10671072
// reduction variable
@@ -1086,7 +1091,11 @@ initReductionVars(OP op, ArrayRef<BlockArgument> reductionArgs,
10861091
assert(phis.size() == 1 && "expected one value to be yielded from the "
10871092
"reduction neutral element declaration region");
10881093

1089-
builder.SetInsertPoint(builder.GetInsertBlock()->getTerminator());
1094+
if (builder.GetInsertBlock()->empty() ||
1095+
builder.GetInsertBlock()->getTerminator() == nullptr)
1096+
builder.SetInsertPoint(builder.GetInsertBlock());
1097+
else
1098+
builder.SetInsertPoint(builder.GetInsertBlock()->getTerminator());
10901099

10911100
if (isByRef[i]) {
10921101
if (!reductionDecls[i].getAllocRegion().empty())
@@ -1271,7 +1280,6 @@ static LogicalResult allocAndInitializeReductionVars(
12711280
if (op.getNumReductionVars() == 0)
12721281
return success();
12731282

1274-
llvm::IRBuilderBase::InsertPointGuard guard(builder);
12751283
SmallVector<DeferredStore> deferredStores;
12761284

12771285
if (failed(allocReductionVars(op, reductionArgs, builder, moduleTranslation,
@@ -2080,6 +2088,8 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
20802088
return llvm::make_error<PreviouslyReportedError>();
20812089

20822090
assert(afterAllocas.get()->getSinglePredecessor());
2091+
builder.restoreIP(codeGenIP);
2092+
20832093
if (failed(
20842094
initReductionVars(opInst, reductionArgs, builder, moduleTranslation,
20852095
afterAllocas.get()->getSinglePredecessor(),
@@ -2099,7 +2109,6 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
20992109
moduleTranslation, allocaIP);
21002110

21012111
// ParallelOp has only one region associated with it.
2102-
builder.restoreIP(codeGenIP);
21032112
llvm::Expected<llvm::BasicBlock *> regionBlock = convertOmpOpRegions(
21042113
opInst.getRegion(), "omp.par.region", builder, moduleTranslation);
21052114
if (!regionBlock)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
2+
3+
// Regression test for https://github.com/llvm/llvm-project/issues/120254.
4+
5+
omp.declare_reduction @add_reduction : !llvm.ptr alloc {
6+
%0 = llvm.mlir.constant(1 : i64) : i64
7+
%1 = llvm.alloca %0 x !llvm.struct<(ptr)> : (i64) -> !llvm.ptr
8+
omp.yield(%1 : !llvm.ptr)
9+
} init {
10+
^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):
11+
%6 = llvm.mlir.constant(1 : i32) : i32
12+
"llvm.intr.memcpy"(%arg1, %arg0, %6) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> ()
13+
omp.yield(%arg1 : !llvm.ptr)
14+
} combiner {
15+
^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):
16+
omp.yield(%arg0 : !llvm.ptr)
17+
} cleanup {
18+
^bb0(%arg0: !llvm.ptr):
19+
omp.yield
20+
}
21+
22+
llvm.func @use_reduction() attributes {fir.bindc_name = "test"} {
23+
%6 = llvm.mlir.constant(1 : i32) : i32
24+
omp.parallel {
25+
%18 = llvm.mlir.constant(1 : i64) : i64
26+
%19 = llvm.alloca %18 x !llvm.struct<(ptr)> : (i64) -> !llvm.ptr
27+
omp.wsloop reduction(byref @add_reduction %19 -> %arg0 : !llvm.ptr) {
28+
omp.loop_nest (%arg1) : i32 = (%6) to (%6) inclusive step (%6) {
29+
omp.yield
30+
}
31+
}
32+
omp.terminator
33+
}
34+
llvm.return
35+
}
36+
37+
// CHECK: omp.par.entry:
38+
// CHECK: %[[RED_REGION_ALLOC:.*]] = alloca { ptr }, i64 1, align 8
39+
40+
// CHECK: omp.par.region:
41+
// CHECK: br label %omp.par.region1
42+
43+
// CHECK: omp.par.region1:
44+
// CHECK: %[[PAR_REG_VAL:.*]] = alloca { ptr }, i64 1, align 8
45+
// CHECK: br label %omp.reduction.init
46+
47+
// CHECK: omp.reduction.init:
48+
// CHECK: call void @llvm.memcpy{{.*}}(ptr %[[RED_REGION_ALLOC]], ptr %[[PAR_REG_VAL]], {{.*}})

mlir/test/Target/LLVMIR/openmp-parallel-reduction-multiblock.mlir

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ llvm.func @missordered_blocks_(%arg0: !llvm.ptr {fir.bindc_name = "x"}, %arg1: !
4444
// CHECK: br label %[[VAL_10:.*]]
4545
// CHECK: omp.par.exit.split: ; preds = %[[VAL_9]]
4646
// CHECK: ret void
47-
// CHECK: omp.par.entry:
47+
// CHECK: [[PAR_ENTRY:omp.par.entry]]:
4848
// CHECK: %[[VAL_11:.*]] = getelementptr { ptr, ptr }, ptr %[[VAL_12:.*]], i32 0, i32 0
4949
// CHECK: %[[VAL_13:.*]] = load ptr, ptr %[[VAL_11]], align 8
5050
// CHECK: %[[VAL_14:.*]] = getelementptr { ptr, ptr }, ptr %[[VAL_12]], i32 0, i32 1
@@ -56,10 +56,12 @@ llvm.func @missordered_blocks_(%arg0: !llvm.ptr {fir.bindc_name = "x"}, %arg1: !
5656
// CHECK: %[[VAL_20:.*]] = alloca ptr, align 8
5757
// CHECK: %[[VAL_21:.*]] = alloca ptr, align 8
5858
// CHECK: %[[VAL_22:.*]] = alloca [2 x ptr], align 8
59-
// CHECK: br label %[[VAL_23:.*]]
60-
// CHECK: omp.reduction.init: ; preds = %[[VAL_24:.*]]
61-
// CHECK: br label %[[VAL_25:.*]]
62-
// CHECK: omp.reduction.neutral: ; preds = %[[VAL_23]]
59+
// CHECK: br label %[[VAL_23:omp.par.region]]
60+
// CHECK: [[VAL_23]]: ; preds = %[[PAR_ENTRY]]
61+
// CHECK: br label %[[VAL_42:.*]]
62+
// CHECK: [[RED_INIT:omp.reduction.init]]:
63+
// CHECK: br label %[[VAL_25:omp.reduction.neutral]]
64+
// CHECK: [[VAL_25]]: ; preds = %[[RED_INIT]]
6365
// CHECK: %[[VAL_26:.*]] = ptrtoint ptr %[[VAL_13]] to i64
6466
// CHECK: %[[VAL_27:.*]] = icmp eq i64 %[[VAL_26]], 0
6567
// CHECK: br i1 %[[VAL_27]], label %[[VAL_28:.*]], label %[[VAL_29:.*]]
@@ -79,15 +81,13 @@ llvm.func @missordered_blocks_(%arg0: !llvm.ptr {fir.bindc_name = "x"}, %arg1: !
7981
// CHECK: br label %[[VAL_38:.*]]
8082
// CHECK: omp.reduction.neutral8: ; preds = %[[VAL_36]], %[[VAL_37]]
8183
// CHECK: br label %[[VAL_39:.*]]
82-
// CHECK: omp.region.cont4: ; preds = %[[VAL_38]]
84+
// CHECK: [[VAL_39]]: ; preds = %[[VAL_38]]
8385
// CHECK: %[[VAL_40:.*]] = phi ptr [ %[[VAL_15]], %[[VAL_38]] ]
8486
// CHECK: store ptr %[[VAL_40]], ptr %[[VAL_21]], align 8
8587
// CHECK: br label %[[VAL_41:.*]]
86-
// CHECK: omp.par.region: ; preds = %[[VAL_39]]
87-
// CHECK: br label %[[VAL_42:.*]]
88-
// CHECK: omp.par.region10: ; preds = %[[VAL_41]]
88+
// CHECK: omp.par.region10: ; preds = %[[VAL_39]]
8989
// CHECK: br label %[[VAL_43:.*]]
90-
// CHECK: omp.region.cont9: ; preds = %[[VAL_42]]
90+
// CHECK: omp.region.cont9: ; preds = %[[VAL_41]]
9191
// CHECK: %[[VAL_44:.*]] = getelementptr inbounds [2 x ptr], ptr %[[VAL_22]], i64 0, i64 0
9292
// CHECK: store ptr %[[VAL_20]], ptr %[[VAL_44]], align 8
9393
// CHECK: %[[VAL_45:.*]] = getelementptr inbounds [2 x ptr], ptr %[[VAL_22]], i64 0, i64 1

mlir/test/Target/LLVMIR/openmp-private.mlir

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ llvm.func @bar(!llvm.ptr)
199199
// CHECK-DAG: %[[RED_ALLOC:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, i64 1, align 8
200200

201201
// CHECK: omp.par.region:
202+
// CHECK: br label %omp.reduction.init
203+
// CHECK: omp.reduction.init:
202204
// CHECK: br label %[[PAR_REG_BEG:.*]]
203205
// CHECK: [[PAR_REG_BEG]]:
204206
// CHECK-NEXT: %{{.*}} = load { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %[[RED_ALLOC]], align 8

mlir/test/Target/LLVMIR/openmp-reduction-array-sections.mlir

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ llvm.func @sectionsreduction_(%arg0: !llvm.ptr {fir.bindc_name = "x"}) attribute
7777
}
7878

7979
// CHECK-LABEL: define internal void @sectionsreduction_..omp_par
80-
// CHECK: omp.par.entry:
80+
// CHECK: [[PAR_ENTRY:omp.par.entry]]:
8181
// CHECK: %[[VAL_6:.*]] = alloca i32, align 4
8282
// CHECK: %[[VAL_7:.*]] = alloca i32, align 4
8383
// CHECK: %[[VAL_8:.*]] = alloca i32, align 4
@@ -90,15 +90,18 @@ llvm.func @sectionsreduction_(%arg0: !llvm.ptr {fir.bindc_name = "x"}) attribute
9090
// CHECK: %[[VAL_21:.*]] = alloca ptr, align 8
9191
// CHECK: %[[VAL_14:.*]] = alloca [1 x ptr], align 8
9292
// CHECK: br label %[[VAL_15:.*]]
93-
// CHECK: omp.reduction.init: ; preds = %[[VAL_16:.*]]
94-
// CHECK: store ptr %[[VAL_20]], ptr %[[VAL_21]], align 8
95-
// CHECK: br label %[[VAL_17:.*]]
96-
// CHECK: omp.par.region: ; preds = %[[VAL_15]]
93+
94+
// CHECK: omp.par.region: ; preds = %[[PAR_ENTRY]]
9795
// CHECK: br label %[[VAL_18:.*]]
98-
// CHECK: omp.par.region1: ; preds = %[[VAL_17]]
96+
// CHECK: omp.par.region1: ; preds = %[[VAL_15]]
9997
// CHECK: %[[VAL_19:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, i64 1, align 8
10098
// CHECK: br label %[[VAL_22:.*]]
101-
// CHECK: omp_section_loop.preheader: ; preds = %[[VAL_18]]
99+
100+
// CHECK: omp.reduction.init: ; preds = %[[VAL_16:.*]]
101+
// CHECK: store ptr %[[VAL_20]], ptr %[[VAL_21]], align 8
102+
// CHECK: br label %[[VAL_17:.*]]
103+
104+
// CHECK: omp_section_loop.preheader: ; preds = %[[VAL_22]]
102105
// CHECK: store i32 0, ptr %[[VAL_7]], align 4
103106
// CHECK: store i32 1, ptr %[[VAL_8]], align 4
104107
// CHECK: store i32 1, ptr %[[VAL_9]], align 4
@@ -109,8 +112,8 @@ llvm.func @sectionsreduction_(%arg0: !llvm.ptr {fir.bindc_name = "x"}) attribute
109112
// CHECK: %[[VAL_26:.*]] = sub i32 %[[VAL_25]], %[[VAL_24]]
110113
// CHECK: %[[VAL_27:.*]] = add i32 %[[VAL_26]], 1
111114
// CHECK: br label %[[VAL_28:.*]]
112-
// CHECK: omp_section_loop.header: ; preds = %[[VAL_29:.*]], %[[VAL_22]]
113-
// CHECK: %[[VAL_30:.*]] = phi i32 [ 0, %[[VAL_22]] ], [ %[[VAL_31:.*]], %[[VAL_29]] ]
115+
// CHECK: omp_section_loop.header: ; preds = %[[VAL_29:.*]], %[[VAL_17]]
116+
// CHECK: %[[VAL_30:.*]] = phi i32 [ 0, %[[VAL_17]] ], [ %[[VAL_31:.*]], %[[VAL_29]] ]
114117
// CHECK: br label %[[VAL_32:.*]]
115118
// CHECK: omp_section_loop.cond: ; preds = %[[VAL_28]]
116119
// CHECK: %[[VAL_33:.*]] = icmp ult i32 %[[VAL_30]], %[[VAL_27]]

mlir/test/Target/LLVMIR/openmp-reduction-init-arg.mlir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module {
5050
// CHECK: br label %[[VAL_10:.*]]
5151
// CHECK: omp.par.exit.split: ; preds = %[[VAL_9]]
5252
// CHECK: ret void
53-
// CHECK: omp.par.entry:
53+
// CHECK: [[PAR_ENTRY:omp.par.entry]]:
5454
// CHECK: %[[VAL_11:.*]] = getelementptr { ptr, ptr }, ptr %[[VAL_12:.*]], i32 0, i32 0
5555
// CHECK: %[[VAL_13:.*]] = load ptr, ptr %[[VAL_11]], align 8
5656
// CHECK: %[[VAL_14:.*]] = getelementptr { ptr, ptr }, ptr %[[VAL_12]], i32 0, i32 1
@@ -62,16 +62,16 @@ module {
6262
// CHECK: %[[VAL_21:.*]] = alloca ptr, align 8
6363
// CHECK: %[[VAL_23:.*]] = alloca ptr, align 8
6464
// CHECK: %[[VAL_24:.*]] = alloca [2 x ptr], align 8
65+
// CHECK: br label %[[VAL_25:.*]]
66+
// CHECK: omp.par.region: ; preds = %[[PAR_ENTRY]]
6567
// CHECK: br label %[[INIT_LABEL:.*]]
6668
// CHECK: [[INIT_LABEL]]:
6769
// CHECK: %[[VAL_20:.*]] = load { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %[[VAL_13]], align 8
6870
// CHECK: store ptr %[[VAL_13]], ptr %[[VAL_21]], align 8
6971
// CHECK: %[[VAL_22:.*]] = load { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %[[VAL_15]], align 8
7072
// CHECK: store ptr %[[VAL_15]], ptr %[[VAL_23]], align 8
71-
// CHECK: br label %[[VAL_25:.*]]
72-
// CHECK: omp.par.region: ; preds = %[[VAL_26:.*]]
7373
// CHECK: br label %[[VAL_27:.*]]
74-
// CHECK: omp.par.region1: ; preds = %[[VAL_25]]
74+
// CHECK: omp.par.region1: ; preds = %[[INIT_LABEL]]
7575
// CHECK: br label %[[VAL_28:.*]]
7676
// CHECK: omp.region.cont: ; preds = %[[VAL_27]]
7777
// CHECK: %[[VAL_29:.*]] = getelementptr inbounds [2 x ptr], ptr %[[VAL_24]], i64 0, i64 0

mlir/test/Target/LLVMIR/openmp-reduction-sections.mlir

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ llvm.func @sections_(%arg0: !llvm.ptr {fir.bindc_name = "x"}) attributes {fir.in
3636
}
3737

3838
// CHECK-LABEL: define internal void @sections_..omp_par
39-
// CHECK: omp.par.entry:
39+
// CHECK: [[PAR_ENTRY:omp.par.entry]]:
4040
// CHECK: %[[VAL_9:.*]] = getelementptr { ptr }, ptr %[[VAL_10:.*]], i32 0, i32 0
4141
// CHECK: %[[VAL_11:.*]] = load ptr, ptr %[[VAL_9]], align 8
4242
// CHECK: %[[VAL_12:.*]] = alloca i32, align 4
@@ -50,14 +50,16 @@ llvm.func @sections_(%arg0: !llvm.ptr {fir.bindc_name = "x"}) attributes {fir.in
5050
// CHECK: %[[VAL_20:.*]] = alloca float, align 4
5151
// CHECK: %[[VAL_21:.*]] = alloca [1 x ptr], align 8
5252
// CHECK: br label %[[VAL_22:.*]]
53-
// CHECK: omp.reduction.init: ; preds = %[[VAL_23:.*]]
54-
// CHECK: store float 0.000000e+00, ptr %[[VAL_20]], align 4
55-
// CHECK: br label %[[VAL_24:.*]]
56-
// CHECK: omp.par.region: ; preds = %[[VAL_22]]
53+
// CHECK: omp.par.region: ; preds = %[[PAR_ENTRY]]
5754
// CHECK: br label %[[VAL_25:.*]]
58-
// CHECK: omp.par.region1: ; preds = %[[VAL_24]]
55+
// CHECK: omp.par.region1: ; preds = %[[VAL_22]]
5956
// CHECK: br label %[[VAL_26:.*]]
60-
// CHECK: omp_section_loop.preheader: ; preds = %[[VAL_25]]
57+
58+
// CHECK: [[RED_INIT:omp.reduction.init]]:
59+
// CHECK: store float 0.000000e+00, ptr %[[VAL_20]], align 4
60+
// CHECK: br label %[[VAL_24:.*]]
61+
62+
// CHECK: omp_section_loop.preheader: ; preds = %[[RED_INIT]]
6163
// CHECK: store i32 0, ptr %[[VAL_13]], align 4
6264
// CHECK: store i32 1, ptr %[[VAL_14]], align 4
6365
// CHECK: store i32 1, ptr %[[VAL_15]], align 4
@@ -68,8 +70,8 @@ llvm.func @sections_(%arg0: !llvm.ptr {fir.bindc_name = "x"}) attributes {fir.in
6870
// CHECK: %[[VAL_30:.*]] = sub i32 %[[VAL_29]], %[[VAL_28]]
6971
// CHECK: %[[VAL_31:.*]] = add i32 %[[VAL_30]], 1
7072
// CHECK: br label %[[VAL_32:.*]]
71-
// CHECK: omp_section_loop.header: ; preds = %[[VAL_33:.*]], %[[VAL_26]]
72-
// CHECK: %[[VAL_34:.*]] = phi i32 [ 0, %[[VAL_26]] ], [ %[[VAL_35:.*]], %[[VAL_33]] ]
73+
// CHECK: omp_section_loop.header: ; preds = %[[VAL_33:.*]], %[[VAL_24]]
74+
// CHECK: %[[VAL_34:.*]] = phi i32 [ 0, %[[VAL_24]] ], [ %[[VAL_35:.*]], %[[VAL_33]] ]
7375
// CHECK: br label %[[VAL_36:.*]]
7476
// CHECK: omp_section_loop.cond: ; preds = %[[VAL_32]]
7577
// CHECK: %[[VAL_37:.*]] = icmp ult i32 %[[VAL_34]], %[[VAL_31]]

0 commit comments

Comments
 (0)