llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-flang-fir-hlfir Author: Tom Eccles (tblah) <details> <summary>Changes</summary> I removed the `*-hlfir*` tests because they are duplicate now that the other tests have been updated to use the HLFIR lowering. 3/3 Part 1: https://github.com/llvm/llvm-project/pull/102522 Part 2: https://github.com/llvm/llvm-project/pull/102524 --- Patch is 87.14 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/102525.diff 35 Files Affected: - (modified) flang/lib/Lower/OpenMP/ReductionProcessor.cpp (+63-23) - (modified) flang/test/Lower/OpenMP/delayed-privatization-reduction-byref.f90 (+1-1) - (modified) flang/test/Lower/OpenMP/parallel-reduction-add-byref.f90 (+12-8) - (modified) flang/test/Lower/OpenMP/parallel-reduction-allocatable-array.f90 (+8-6) - (modified) flang/test/Lower/OpenMP/parallel-reduction-array-lb.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/parallel-reduction-array.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/parallel-reduction-array2.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/parallel-reduction-byref.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/parallel-reduction-mixed.f90 (+2-2) - (modified) flang/test/Lower/OpenMP/parallel-reduction-pointer-array.f90 (+8-6) - (modified) flang/test/Lower/OpenMP/parallel-reduction3.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/reduction-array-intrinsic.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/sections-array-reduction.f90 (+4-1) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-add-byref.f90 (+28-20) - (removed) flang/test/Lower/OpenMP/wsloop-reduction-add-hlfir-byref.f90 (-58) - (removed) flang/test/Lower/OpenMP/wsloop-reduction-add-hlfir.f90 (-54) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-allocatable-array-minmax.f90 (+16-12) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-allocatable.f90 (+8-6) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-array-assumed-shape.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-array.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-array2.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-iand-byref.f90 (+6-4) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-ieor-byref.f90 (+6-4) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-ior-byref.f90 (+6-4) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-logical-and-byref.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-logical-eqv-byref.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-logical-neqv-byref.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-logical-or-byref.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-max-byref.f90 (+11-7) - (removed) flang/test/Lower/OpenMP/wsloop-reduction-max-hlfir-byref.f90 (-64) - (removed) flang/test/Lower/OpenMP/wsloop-reduction-max-hlfir.f90 (-60) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-min-byref.f90 (+11-7) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-mul-byref.f90 (+24-16) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-multiple-clauses.f90 (+7-5) - (modified) flang/test/Lower/OpenMP/wsloop-reduction-pointer.f90 (+5-3) ``````````diff diff --git a/flang/lib/Lower/OpenMP/ReductionProcessor.cpp b/flang/lib/Lower/OpenMP/ReductionProcessor.cpp index c3c1f363033c27..c87182abe3d187 100644 --- a/flang/lib/Lower/OpenMP/ReductionProcessor.cpp +++ b/flang/lib/Lower/OpenMP/ReductionProcessor.cpp @@ -489,23 +489,57 @@ static mlir::Type unwrapSeqOrBoxedType(mlir::Type ty) { return ty; } -static mlir::Value -createReductionInitRegion(fir::FirOpBuilder &builder, mlir::Location loc, - mlir::omp::DeclareReductionOp &reductionDecl, - const ReductionProcessor::ReductionIdentifier redId, - mlir::Type type, bool isByRef) { +static void createReductionAllocAndInitRegions( + fir::FirOpBuilder &builder, mlir::Location loc, + mlir::omp::DeclareReductionOp &reductionDecl, + const ReductionProcessor::ReductionIdentifier redId, mlir::Type type, + bool isByRef) { + auto yield = [&](mlir::Value ret) { + builder.create<mlir::omp::YieldOp>(loc, ret); + }; + + mlir::Block *allocBlock = nullptr; + mlir::Block *initBlock = nullptr; + if (isByRef) { + allocBlock = + builder.createBlock(&reductionDecl.getAllocRegion(), + reductionDecl.getAllocRegion().end(), {}, {}); + initBlock = builder.createBlock(&reductionDecl.getInitializerRegion(), + reductionDecl.getInitializerRegion().end(), + {type, type}, {loc, loc}); + } else { + initBlock = builder.createBlock(&reductionDecl.getInitializerRegion(), + reductionDecl.getInitializerRegion().end(), + {type}, {loc}); + } + mlir::Type ty = fir::unwrapRefType(type); + builder.setInsertionPointToEnd(initBlock); mlir::Value initValue = ReductionProcessor::getReductionInitValue( loc, unwrapSeqOrBoxedType(ty), redId, builder); if (fir::isa_trivial(ty)) { if (isByRef) { - mlir::Value alloca = builder.create<fir::AllocaOp>(loc, ty); - builder.createStoreWithConvert(loc, initValue, alloca); - return alloca; + // alloc region + { + builder.setInsertionPointToEnd(allocBlock); + mlir::Value alloca = builder.create<fir::AllocaOp>(loc, ty); + yield(alloca); + } + + // init region + { + builder.setInsertionPointToEnd(initBlock); + // block arg is mapped to the alloca yielded from the alloc region + mlir::Value alloc = reductionDecl.getInitializerAllocArg(); + builder.createStoreWithConvert(loc, initValue, alloc); + yield(alloc); + } + return; } // by val - return initValue; + yield(initValue); + return; } // check if an allocatable box is unallocated. If so, initialize the boxAlloca @@ -520,10 +554,10 @@ createReductionInitRegion(fir::FirOpBuilder &builder, mlir::Location loc, // fir.store %something to %box_alloca // } // omp.yield %box_alloca - mlir::Value blockArg = - builder.loadIfRef(loc, builder.getBlock()->getArgument(0)); + mlir::Value moldArg = + builder.loadIfRef(loc, reductionDecl.getInitializerMoldArg()); auto handleNullAllocatable = [&](mlir::Value boxAlloca) -> fir::IfOp { - mlir::Value addr = builder.create<fir::BoxAddrOp>(loc, blockArg); + mlir::Value addr = builder.create<fir::BoxAddrOp>(loc, moldArg); mlir::Value isNotAllocated = builder.genIsNullAddr(loc, addr); fir::IfOp ifOp = builder.create<fir::IfOp>(loc, isNotAllocated, /*withElseRegion=*/true); @@ -539,7 +573,17 @@ createReductionInitRegion(fir::FirOpBuilder &builder, mlir::Location loc, assert(isByRef && "passing boxes by value is unsupported"); bool isAllocatableOrPointer = mlir::isa<fir::HeapType, fir::PointerType>(boxTy.getEleTy()); - mlir::Value boxAlloca = builder.create<fir::AllocaOp>(loc, ty); + + // alloc region + { + builder.setInsertionPointToEnd(allocBlock); + mlir::Value boxAlloca = builder.create<fir::AllocaOp>(loc, ty); + yield(boxAlloca); + } + + // init region + builder.setInsertionPointToEnd(initBlock); + mlir::Value boxAlloca = reductionDecl.getInitializerAllocArg(); mlir::Type innerTy = fir::unwrapRefType(boxTy.getEleTy()); if (fir::isa_trivial(innerTy)) { // boxed non-sequence value e.g. !fir.box<!fir.heap<i32>> @@ -558,7 +602,8 @@ createReductionInitRegion(fir::FirOpBuilder &builder, mlir::Location loc, createReductionCleanupRegion(builder, loc, reductionDecl); builder.restoreInsertionPoint(insPt); builder.setInsertionPointAfter(ifUnallocated); - return boxAlloca; + yield(boxAlloca); + return; } innerTy = fir::extractSequenceType(boxTy); if (!mlir::isa<fir::SequenceType>(innerTy)) @@ -571,7 +616,7 @@ createReductionInitRegion(fir::FirOpBuilder &builder, mlir::Location loc, } // Create the private copy from the initial fir.box: - mlir::Value loadedBox = builder.loadIfRef(loc, blockArg); + mlir::Value loadedBox = builder.loadIfRef(loc, moldArg); hlfir::Entity source = hlfir::Entity{loadedBox}; // Allocating on the heap in case the whole reduction is nested inside of a @@ -616,7 +661,8 @@ createReductionInitRegion(fir::FirOpBuilder &builder, mlir::Location loc, builder.create<fir::StoreOp>(loc, box, boxAlloca); if (ifUnallocated) builder.setInsertionPointAfter(ifUnallocated); - return boxAlloca; + yield(boxAlloca); + return; } TODO(loc, "createReductionInitRegion for unsupported type"); @@ -643,13 +689,7 @@ mlir::omp::DeclareReductionOp ReductionProcessor::createDeclareReduction( decl = modBuilder.create<mlir::omp::DeclareReductionOp>(loc, reductionOpName, type); - builder.createBlock(&decl.getInitializerRegion(), - decl.getInitializerRegion().end(), {type}, {loc}); - builder.setInsertionPointToEnd(&decl.getInitializerRegion().back()); - - mlir::Value init = - createReductionInitRegion(builder, loc, decl, redId, type, isByRef); - builder.create<mlir::omp::YieldOp>(loc, init); + createReductionAllocAndInitRegions(builder, loc, decl, redId, type, isByRef); builder.createBlock(&decl.getReductionRegion(), decl.getReductionRegion().end(), {type, type}, diff --git a/flang/test/Lower/OpenMP/delayed-privatization-reduction-byref.f90 b/flang/test/Lower/OpenMP/delayed-privatization-reduction-byref.f90 index 72e91680a43104..29439571179322 100644 --- a/flang/test/Lower/OpenMP/delayed-privatization-reduction-byref.f90 +++ b/flang/test/Lower/OpenMP/delayed-privatization-reduction-byref.f90 @@ -22,7 +22,7 @@ subroutine red_and_delayed_private ! CHECK-SAME: @[[PRIVATIZER_SYM:.*]] : !fir.ref<i32> alloc { ! CHECK-LABEL: omp.declare_reduction -! CHECK-SAME: @[[REDUCTION_SYM:.*]] : !fir.ref<i32> init +! CHECK-SAME: @[[REDUCTION_SYM:.*]] : !fir.ref<i32> alloc ! CHECK-LABEL: _QPred_and_delayed_private ! CHECK: omp.parallel diff --git a/flang/test/Lower/OpenMP/parallel-reduction-add-byref.f90 b/flang/test/Lower/OpenMP/parallel-reduction-add-byref.f90 index 7347d9324feac8..ad97b17d6857d6 100644 --- a/flang/test/Lower/OpenMP/parallel-reduction-add-byref.f90 +++ b/flang/test/Lower/OpenMP/parallel-reduction-add-byref.f90 @@ -3,12 +3,14 @@ !CHECK-LABEL: omp.declare_reduction !CHECK-SAME: @[[RED_F32_NAME:.*]] : !fir.ref<f32> -!CHECK-SAME: init { -!CHECK: ^bb0(%{{.*}}: !fir.ref<f32>): -!CHECK: %[[C0_1:.*]] = arith.constant 0.000000e+00 : f32 +!CHECK-SAME: alloc { !CHECK: %[[REF:.*]] = fir.alloca f32 -!CHECKL fir.store [[%C0_1]] to %[[REF]] : !fir.ref<f32> !CHECK: omp.yield(%[[REF]] : !fir.ref<f32>) +!CHECK-LABEL: } init { +!CHECK: ^bb0(%{{.*}}: !fir.ref<f32>, %[[ALLOC:.*]]: !fir.ref<f32>): +!CHECK: %[[C0_1:.*]] = arith.constant 0.000000e+00 : f32 +!CHECKL fir.store [[%C0_1]] to %[[ALLOC]] : !fir.ref<f32> +!CHECK: omp.yield(%[[ALLOC]] : !fir.ref<f32>) !CHECK: } combiner { !CHECK: ^bb0(%[[ARG0:.*]]: !fir.ref<f32>, %[[ARG1:.*]]: !fir.ref<f32>): !CHECK: %[[LD0:.*]] = fir.load %[[ARG0]] : !fir.ref<f32> @@ -20,12 +22,14 @@ !CHECK-LABEL: omp.declare_reduction !CHECK-SAME: @[[RED_I32_NAME:.*]] : !fir.ref<i32> -!CHECK-SAME: init { -!CHECK: ^bb0(%{{.*}}: !fir.ref<i32>): -!CHECK: %[[C0_1:.*]] = arith.constant 0 : i32 +!CHECK-SAME: alloc { !CHECK: %[[REF:.*]] = fir.alloca i32 -!CHECK: fir.store %[[C0_1]] to %[[REF]] : !fir.ref<i32> !CHECK: omp.yield(%[[REF]] : !fir.ref<i32>) +!CHECK-LABEL: } init { +!CHECK: ^bb0(%{{.*}}: !fir.ref<i32>, %[[ALLOC:.*]]: !fir.ref<i32>): +!CHECK: %[[C0_1:.*]] = arith.constant 0 : i32 +!CHECK: fir.store %[[C0_1]] to %[[ALLOC]] : !fir.ref<i32> +!CHECK: omp.yield(%[[ALLOC]] : !fir.ref<i32>) !CHECK: } combiner { !CHECK: ^bb0(%[[ARG0:.*]]: !fir.ref<i32>, %[[ARG1:.*]]: !fir.ref<i32>): !CHECK: %[[LD0:.*]] = fir.load %[[ARG0]] : !fir.ref<i32> diff --git a/flang/test/Lower/OpenMP/parallel-reduction-allocatable-array.f90 b/flang/test/Lower/OpenMP/parallel-reduction-allocatable-array.f90 index fdb7e974f1c5c6..7a2db3299784c7 100644 --- a/flang/test/Lower/OpenMP/parallel-reduction-allocatable-array.f90 +++ b/flang/test/Lower/OpenMP/parallel-reduction-allocatable-array.f90 @@ -18,18 +18,20 @@ program reduce end program -! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_heap_Uxi32 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> init { -! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>): +! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_heap_Uxi32 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> alloc { +! CHECK: %[[VAL_10:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> +! CHECK: omp.yield(%[[VAL_10]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) +! CHECK-LABEL: } init { +! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, %[[ALLOC:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>): ! CHECK: %[[VAL_1:.*]] = arith.constant 0 : i32 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> -! CHECK: %[[VAL_10:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> ! CHECK: %[[ADDR:.*]] = fir.box_addr %[[VAL_2]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>> ! CHECK: %[[ADDRI:.*]] = fir.convert %[[ADDR]] : (!fir.heap<!fir.array<?xi32>>) -> i64 ! CHECK: %[[C0_I64:.*]] = arith.constant 0 : i64 ! CHECK: %[[IS_NULL:.*]] = arith.cmpi eq, %[[ADDRI]], %[[C0_I64]] : i64 ! CHECK: fir.if %[[IS_NULL]] { ! CHECK: %[[NULL_BOX:.*]] = fir.embox %[[ADDR]] : (!fir.heap<!fir.array<?xi32>>) -> !fir.box<!fir.heap<!fir.array<?xi32>>> -! CHECK: fir.store %[[NULL_BOX]] to %[[VAL_10]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> +! CHECK: fir.store %[[NULL_BOX]] to %[[ALLOC]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> ! CHECK: } else { ! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_4:.*]]:3 = fir.box_dims %[[VAL_2]], %[[VAL_3]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>, index) -> (index, index, index) @@ -42,9 +44,9 @@ program reduce ! CHECK: %[[SHIFT:.*]] = fir.shape_shift %[[DIMS]]#0, %[[DIMS]]#1 : (index, index) -> !fir.shapeshift<1> ! CHECK: %[[REBOX:.*]] = fir.rebox %[[VAL_8]]#0(%[[SHIFT]]) : (!fir.box<!fir.array<?xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.heap<!fir.array<?xi32>>> ! CHECK: hlfir.assign %[[VAL_1]] to %[[REBOX]] : i32, !fir.box<!fir.heap<!fir.array<?xi32>>> -! CHECK: fir.store %[[REBOX]] to %[[VAL_10]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> +! CHECK: fir.store %[[REBOX]] to %[[ALLOC]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> ! CHECK: } -! CHECK: omp.yield(%[[VAL_10]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) +! CHECK: omp.yield(%[[ALLOC]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) ! CHECK: } combiner { ! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, %[[VAL_1:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>): ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> diff --git a/flang/test/Lower/OpenMP/parallel-reduction-array-lb.f90 b/flang/test/Lower/OpenMP/parallel-reduction-array-lb.f90 index b44fe4c1f4cc28..59902bd13a1c2e 100644 --- a/flang/test/Lower/OpenMP/parallel-reduction-array-lb.f90 +++ b/flang/test/Lower/OpenMP/parallel-reduction-array-lb.f90 @@ -12,11 +12,13 @@ program reduce end program -! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_3x2xi32 : !fir.ref<!fir.box<!fir.array<3x2xi32>>> init { -! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.array<3x2xi32>>>): +! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_3x2xi32 : !fir.ref<!fir.box<!fir.array<3x2xi32>>> alloc { +! CHECK: %[[VAL_15:.*]] = fir.alloca !fir.box<!fir.array<3x2xi32>> +! CHECK: omp.yield(%[[VAL_15]] : !fir.ref<!fir.box<!fir.array<3x2xi32>>>) +! CHECK-LABEL: } init { +! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.array<3x2xi32>>>, %[[ALLOC:.*]]: !fir.ref<!fir.box<!fir.array<3x2xi32>>>): ! CHECK: %[[VAL_1:.*]] = arith.constant 0 : i32 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.array<3x2xi32>>> -! CHECK: %[[VAL_15:.*]] = fir.alloca !fir.box<!fir.array<3x2xi32>> ! CHECK: %[[VAL_3:.*]] = arith.constant 3 : index ! CHECK: %[[VAL_4:.*]] = arith.constant 2 : index ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_3]], %[[VAL_4]] : (index, index) -> !fir.shape<2> @@ -30,8 +32,8 @@ program reduce ! CHECK: %[[VAL_13:.*]] = fir.shape_shift %[[VAL_10]]#0, %[[VAL_10]]#1, %[[VAL_12]]#0, %[[VAL_12]]#1 : (index, index, index, index) -> !fir.shapeshift<2> ! CHECK: %[[VAL_14:.*]] = fir.embox %[[VAL_8]]#0(%[[VAL_13]]) : (!fir.heap<!fir.array<3x2xi32>>, !fir.shapeshift<2>) -> !fir.box<!fir.array<3x2xi32>> ! CHECK: hlfir.assign %[[VAL_1]] to %[[VAL_14]] : i32, !fir.box<!fir.array<3x2xi32>> -! CHECK: fir.store %[[VAL_14]] to %[[VAL_15]] : !fir.ref<!fir.box<!fir.array<3x2xi32>>> -! CHECK: omp.yield(%[[VAL_15]] : !fir.ref<!fir.box<!fir.array<3x2xi32>>>) +! CHECK: fir.store %[[VAL_14]] to %[[ALLOC]] : !fir.ref<!fir.box<!fir.array<3x2xi32>>> +! CHECK: omp.yield(%[[ALLOC]] : !fir.ref<!fir.box<!fir.array<3x2xi32>>>) ! CHECK: } combiner { ! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.array<3x2xi32>>>, %[[VAL_1:.*]]: !fir.ref<!fir.box<!fir.array<3x2xi32>>>): ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.array<3x2xi32>>> diff --git a/flang/test/Lower/OpenMP/parallel-reduction-array.f90 b/flang/test/Lower/OpenMP/parallel-reduction-array.f90 index 60b21c9b1ebbe0..8835c1f5b5e18d 100644 --- a/flang/test/Lower/OpenMP/parallel-reduction-array.f90 +++ b/flang/test/Lower/OpenMP/parallel-reduction-array.f90 @@ -13,11 +13,13 @@ program reduce print *,i end program -! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_3xi32 : !fir.ref<!fir.box<!fir.array<3xi32>>> init { -! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.array<3xi32>>>): +! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_3xi32 : !fir.ref<!fir.box<!fir.array<3xi32>>> alloc { +! CHECK: %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.array<3xi32>> +! CHECK: omp.yield(%[[VAL_8]] : !fir.ref<!fir.box<!fir.array<3xi32>>>) +! CHECK-LABEL: } init { +! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.array<3xi32>>>, %[[ALLOC:.*]]: !fir.ref<!fir.box<!fir.array<3xi32>>>): ! CHECK: %[[VAL_2:.*]] = arith.constant 0 : i32 ! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.array<3xi32>>> -! CHECK: %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.array<3xi32>> ! CHECK: %[[VAL_4:.*]] = arith.constant 3 : index ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1> ! CHECK: %[[VAL_1:.*]] = fir.allocmem !fir.array<3xi32> {bindc_name = ".tmp", uniq_name = ""} @@ -29,8 +31,8 @@ program reduce ! CHECK: %[[SHIFT:.*]] = fir.shape_shift %[[DIMS]]#0, %[[DIMS]]#1 : (index, index) -> !fir.shapeshift<1> ! CHECK: %[[VAL_7:.*]] = fir.embox %[[VAL_6]]#0(%[[SHIFT]]) : (!fir.heap<!fir.array<3xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<3xi32>> ! CHECK: hlfir.assign %[[VAL_2]] to %[[VAL_7]] : i32, !fir.box<!fir.array<3xi32>> -! CHECK: fir.store %[[VAL_7]] to %[[VAL_8]] : !fir.ref<!fir.box<!fir.array<3xi32>>> -! CHECK: omp.yield(%[[VAL_8]] : !fir.ref<!fir.box<!fir.array<3xi32>>>) +! CHECK: fir.store %[[VAL_7]] to %[[ALLOC]] : !fir.ref<!fir.box<!fir.array<3xi32>>> +! CHECK: omp.yield(%[[ALLOC]] : !fir.ref<!fir.box<!fir.array<3xi32>>>) ! CHECK: } combiner { ! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.array<3xi32>>>, %[[VAL_1:.*]]: !fir.ref<!fir.box<!fir.array<3xi32>>>): ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.array<3xi32>>> diff --git a/flang/test/Lower/OpenMP/parallel-reduction-array2.f90 b/flang/test/Lower/OpenMP/parallel-reduction-array2.f90 index 5d4c86d1d76e84..2d4c0239b5d2e6 100644 --- a/flang/test/Lower/OpenMP/parallel-reduction-array2.f90 +++ b/flang/test/Lower/OpenMP/parallel-reduction-array2.f90 @@ -13,11 +13,13 @@ program reduce print *,i end program -! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_3xi32 : !fir.ref<!fir.box<!fir.array<3xi32>>> init { -! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.array<3xi32>>>): +! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_3xi32 : !fir.ref<!fir.box<!fir.array<3xi32>>> alloc { +! CHECK: %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.array<3xi32>> +! CHECK: omp.yield(%[[VAL_8]] : !fir.ref<!fir.box<!fir.array<3xi32>>>) +! CHECK-LABEL: } init { +! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.array<3xi32>>>, %[[ALLOC:.*]]: !fir.ref<!fir.box<!fir.array<3xi32>>>): ! CHECK: %[[VAL_2:.*]] = arith.constant 0 : i32 ! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.array<3xi32>>> -! CHECK: %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.array<3xi32>> ! CHECK: %[[VAL_4:.*]] = arith.constant 3 : index ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1> ! CHECK: %[[VAL_1:.*]] = fir.allocmem !fir.array<3xi32> @@ -28,8 +30,8 @@ program reduce ! CHECK: %[[SHIFT:.*]] = fir.shape_shift %[[DIMS]]#0, %[[DIMS]]#1 : (index, index) -> !fir.shapeshift<1> ! CHECK: %[[VAL_7:.*]] = fir.embox %[[VAL_6]]#0(%[[SHIFT]]) : (!fir.heap<!fir.array<3xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<3xi32>> ! CHECK: hlfir.assign %[[VAL_2]] to %[[VAL_7]] : i32, !fir.box<!fir.array<3xi32>> -! CHECK: fir.store %[[VAL_7]] to %[[VAL_8]] : !fir.ref<!fir.box<!fir.array<3xi32>>> -! CHECK: omp.yield(%[[VAL_8]] : !fir.ref<!fir.box<!fir.array<3xi32>>>) +! CHECK: fir.store %[[VAL_7]] to %[[ALLOC]] : !fir.ref<!fir.box<!fir.array<3xi32>>> +! CHECK: omp.yield(%[[ALLOC]] : !fir.ref<!fir.box<!fir.array<3xi32>>>) ! CHECK: } combiner { ! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.array<3xi32>>>, %[[VAL_1:.*]]: !fir.ref<!fir.box<!fir.array<3xi32>>>): ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.array<3xi32>>> diff --git a/flang/test/Lower/OpenMP/parallel-reduction-byref.f90 b/flang/test/Lower/OpenMP/parallel-reduction-byref.f90 index 5685e2c584ace7..596276a99cafc9 100644 --- a/flang/test/Lower/OpenMP/parallel-reduction-byref.f90 +++ b/flang/test/Lower/OpenMP/parallel-reduction-byref.f90 @@ -2,12 +2,14 @@ ! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --force-byref-reduction -o - %s 2>&1 | FileCheck %s !CHECK: omp.declare_reduction @[[REDUCTION_DECLARE:[_a-z0-9]+]] : !fir.ref<i32> -!CHECK-SAME: init { -!CH... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/102525 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits