@@ -234,7 +234,7 @@ static LogicalResult checkImplementationStatus(Operation &op) {
234234 }
235235 };
236236 auto checkReduction = [&todo](auto op, LogicalResult &result) {
237- if (isa<omp::TeamsOp>(op))
237+ if (isa<omp::TeamsOp>(op) || isa<omp::SimdOp>(op) )
238238 if (!op.getReductionVars ().empty () || op.getReductionByref () ||
239239 op.getReductionSyms ())
240240 result = todo (" reduction" );
@@ -2704,17 +2704,6 @@ convertOmpSimd(Operation &opInst, llvm::IRBuilderBase &builder,
27042704
27052705 PrivateVarsInfo privateVarsInfo (simdOp);
27062706
2707- MutableArrayRef<BlockArgument> reductionArgs =
2708- cast<omp::BlockArgOpenMPOpInterface>(opInst).getReductionBlockArgs ();
2709- DenseMap<Value, llvm::Value *> reductionVariableMap;
2710- SmallVector<llvm::Value *> privateReductionVariables (
2711- simdOp.getNumReductionVars ());
2712- SmallVector<DeferredStore> deferredStores;
2713- SmallVector<omp::DeclareReductionOp> reductionDecls;
2714- collectReductionDecls (simdOp, reductionDecls);
2715- llvm::ArrayRef<bool > isByRef = getIsByRef (simdOp.getReductionByref ());
2716- assert (isByRef.size () == simdOp.getNumReductionVars ());
2717-
27182707 llvm::OpenMPIRBuilder::InsertPointTy allocaIP =
27192708 findAllocaInsertPoint (builder, moduleTranslation);
27202709
@@ -2723,27 +2712,11 @@ convertOmpSimd(Operation &opInst, llvm::IRBuilderBase &builder,
27232712 if (handleError (afterAllocas, opInst).failed ())
27242713 return failure ();
27252714
2726- if (failed (allocReductionVars (simdOp, reductionArgs, builder,
2727- moduleTranslation, allocaIP, reductionDecls,
2728- privateReductionVariables, reductionVariableMap,
2729- deferredStores, isByRef)))
2730- return failure ();
2731-
27322715 if (handleError (initPrivateVars (builder, moduleTranslation, privateVarsInfo),
27332716 opInst)
27342717 .failed ())
27352718 return failure ();
27362719
2737- // TODO: no call to copyFirstPrivateVars?
2738-
2739- assert (afterAllocas.get ()->getSinglePredecessor ());
2740- if (failed (initReductionVars (simdOp, reductionArgs, builder,
2741- moduleTranslation,
2742- afterAllocas.get ()->getSinglePredecessor (),
2743- reductionDecls, privateReductionVariables,
2744- reductionVariableMap, isByRef, deferredStores)))
2745- return failure ();
2746-
27472720 llvm::ConstantInt *simdlen = nullptr ;
27482721 if (std::optional<uint64_t > simdlenVar = simdOp.getSimdlen ())
27492722 simdlen = builder.getInt64 (simdlenVar.value ());
@@ -2788,50 +2761,6 @@ convertOmpSimd(Operation &opInst, llvm::IRBuilderBase &builder,
27882761 : nullptr ,
27892762 order, simdlen, safelen);
27902763
2791- // We now need to reduce the per-simd-lane reduction variable into the
2792- // original variable. This works a bit differently to other reductions (e.g.
2793- // wsloop) because we don't need to call into the OpenMP runtime to handle
2794- // threads: everything happened in this one thread.
2795- for (auto [i, tuple] : llvm::enumerate (
2796- llvm::zip (reductionDecls, isByRef, simdOp.getReductionVars (),
2797- privateReductionVariables))) {
2798- auto [decl, byRef, reductionVar, privateReductionVar] = tuple;
2799-
2800- OwningReductionGen gen = makeReductionGen (decl, builder, moduleTranslation);
2801- llvm::Value *originalVariable = moduleTranslation.lookupValue (reductionVar);
2802- llvm::Type *reductionType = moduleTranslation.convertType (decl.getType ());
2803-
2804- // We have one less load for by-ref case because that load is now inside of
2805- // the reduction region.
2806- llvm::Value *redValue = originalVariable;
2807- if (!byRef)
2808- redValue =
2809- builder.CreateLoad (reductionType, redValue, " red.value." + Twine (i));
2810- llvm::Value *privateRedValue = builder.CreateLoad (
2811- reductionType, privateReductionVar, " red.private.value." + Twine (i));
2812- llvm::Value *reduced;
2813-
2814- auto res = gen (builder.saveIP (), redValue, privateRedValue, reduced);
2815- if (failed (handleError (res, opInst)))
2816- return failure ();
2817- builder.restoreIP (res.get ());
2818-
2819- // For by-ref case, the store is inside of the reduction region.
2820- if (!byRef)
2821- builder.CreateStore (reduced, originalVariable);
2822- }
2823-
2824- // After the construct, deallocate private reduction variables.
2825- SmallVector<Region *> reductionRegions;
2826- llvm::transform (reductionDecls, std::back_inserter (reductionRegions),
2827- [](omp::DeclareReductionOp reductionDecl) {
2828- return &reductionDecl.getCleanupRegion ();
2829- });
2830- if (failed (inlineOmpRegionCleanup (reductionRegions, privateReductionVariables,
2831- moduleTranslation, builder,
2832- " omp.reduction.cleanup" )))
2833- return failure ();
2834-
28352764 return cleanupPrivateVars (builder, moduleTranslation, simdOp.getLoc (),
28362765 privateVarsInfo.llvmVars ,
28372766 privateVarsInfo.privatizers );
0 commit comments