diff --git a/lib/gc/Analysis/CMakeLists.txt b/lib/gc/Analysis/CMakeLists.txt index 865adcb50..61b3e1ca6 100644 --- a/lib/gc/Analysis/CMakeLists.txt +++ b/lib/gc/Analysis/CMakeLists.txt @@ -2,7 +2,7 @@ gc_set_mlir_link_components(MLIR_LINK_COMPONENTS MLIRIR MLIRSupport) -add_mlir_library(GCAnalysis +gc_add_mlir_library(GCAnalysis MatmulConfigAnalysis.cpp ADDITIONAL_HEADER_DIRS @@ -14,6 +14,5 @@ add_mlir_library(GCAnalysis LINK_LIBS PUBLIC ${mlir_dialect_libs} ${MLIR_LINK_COMPONENTS} - ) - -set_property(GLOBAL APPEND PROPERTY GC_PASS_LIBS GCAnalysis) \ No newline at end of file + GcInterface +) \ No newline at end of file diff --git a/lib/gc/Analysis/MatmulConfigAnalysis.cpp b/lib/gc/Analysis/MatmulConfigAnalysis.cpp index ece062d4c..46181bdee 100644 --- a/lib/gc/Analysis/MatmulConfigAnalysis.cpp +++ b/lib/gc/Analysis/MatmulConfigAnalysis.cpp @@ -44,11 +44,10 @@ getCandidate(uint32_t num, uint32_t floor, // factor std::vector candidates; uint32_t upperbound = std::min(num, ceil); - for (uint32_t i = floor; i <= upperbound; i++) { - if (num % i == 0) { + for (uint32_t i = floor; i <= upperbound; i++) + if (num % i == 0) candidates.push_back(i); - } - } + // the pow of 2 uint32_t candidate = 1U; while (candidate < floor) @@ -68,9 +67,8 @@ getCandidate(uint32_t num, uint32_t floor, bool validateThreads(ArrayRef threads, SystemDesc &sysDesc) { uint32_t numThreads = sysDesc.getNumThreads(); uint32_t actualThreads = 1U; - for (uint32_t t : threads) { + for (uint32_t t : threads) actualThreads *= t; - } return actualThreads == numThreads; } @@ -154,9 +152,8 @@ double computationIntensityOnL2Cache(linalg::LinalgOp &linalgOp, config.NBlock * config.KBlock + config.MBlock * config.KBlock; double computationIntensity = FLOPS / memoryConsumption; - if (memoryConsumption * dtypeSize > L2Cache * fullLoadRatio) { + if (memoryConsumption * dtypeSize > L2Cache * fullLoadRatio) computationIntensity /= outOfCachePenalty; - } return 1 / computationIntensity; } @@ -183,19 +180,17 @@ filterConfigByCostModel(ArrayRef configs, double thresholdCost = costs[idx[(size_t)(preserveRatio * configs.size())]]; thresholdCost = threshold < thresholdCost && threshold > 0 ? threshold : thresholdCost; - for (const auto &i : idx) { - if (costs[i] <= thresholdCost) { + for (const auto &i : idx) + if (costs[i] <= thresholdCost) result.push_back(configs[i]); - } - } + LLVM_DEBUG(llvm::dbgs() << "thresholdCost is: " << thresholdCost << "\nbest with cost: " << costs[idx[0]] << "\n" << configs[idx[0]] << "\n worst with cost: " << costs[idx[configs.size() - 1]] << "\n" << configs[idx[configs.size() - 1]] << "\n"); - if (result.empty()) { + if (result.empty()) result = configs; - } return result; } @@ -248,27 +243,23 @@ prepareConfigCandidates(Operation *root, SystemDesc &sysDesc, for (uint32_t MThreads : MThreadsCandidates) { for (uint32_t NThreads : NThreadsCandidates) { for (uint32_t KThreads : KThreadsCandidates) { - if (!validateThreads({MThreads, NThreads, KThreads}, sysDesc)) { + if (!validateThreads({MThreads, NThreads, KThreads}, sysDesc)) continue; - } for (uint32_t MBlock : MBlockCandidates) { for (uint32_t innerMostMBlock : innerMostMBlockCandidates) { if (MBlock % innerMostMBlock != 0 || - shape[0] % innerMostMBlock != 0) { + shape[0] % innerMostMBlock != 0) continue; - } for (uint32_t NBlock : NBlockCandidates) { for (uint32_t innerMostNBlock : innerMostNBlockCandidates) { if (NBlock % innerMostNBlock != 0 || - shape[1] % innerMostNBlock != 0) { + shape[1] % innerMostNBlock != 0) continue; - } for (uint32_t KBlock : KBlockCandidates) { for (uint32_t innerMostKBlock : innerMostKBlockCandidates) { if (KBlock % innerMostKBlock != 0 || - shape[2] % innerMostKBlock != 0) { + shape[2] % innerMostKBlock != 0) continue; - } MatmulConfig config{ MThreads, NThreads, KThreads, MBlock, NBlock, KBlock, @@ -293,14 +284,12 @@ bool validateConfig(const MatmulConfig &cfg) { if (cfg.MThreads <= 0 || cfg.NThreads <= 0 || cfg.KThreads <= 0 || cfg.MBlock <= 0 || cfg.NBlock <= 0 || cfg.KBlock <= 0 || cfg.innerMostMBlock <= 0 || cfg.innerMostNBlock <= 0 || - cfg.innerMostKBlock <= 0) { + cfg.innerMostKBlock <= 0) return false; - } if (cfg.MBlock % cfg.innerMostMBlock != 0 || cfg.NBlock % cfg.innerMostNBlock != 0 || - cfg.KBlock % cfg.innerMostKBlock != 0) { + cfg.KBlock % cfg.innerMostKBlock != 0) return false; - } return true; } @@ -371,19 +360,16 @@ MatmulConfigAnalysis::MatmulConfigAnalysis(Operation *root) { uint32_t M = 1U, N = 1U, K = 1U; for (auto &&[s, dimType] : llvm::zip(linalgOp.getShape(linalgOp.getDpsInputOperand(0)), - oprandDimType[0])) { - if (dimType == DimType::M) { + oprandDimType[0])) + if (dimType == DimType::M) M *= s; - } - } for (auto &&[s, dimType] : llvm::zip(linalgOp.getShape(linalgOp.getDpsInputOperand(1)), oprandDimType[1])) { - if (dimType == DimType::N) { + if (dimType == DimType::N) N *= s; - } else if (dimType == DimType::K) { + else if (dimType == DimType::K) K *= s; - } } // innermost Block, if the layout is blockied layout, the innermost block @@ -395,30 +381,30 @@ MatmulConfigAnalysis::MatmulConfigAnalysis(Operation *root) { SmallVector givenInnermostBlock; if (MDimTypeIdx.size() > 1) { config.innerMostMBlock = 1; - for (size_t i = 1UL; i < MDimTypeIdx.size(); i++) { - config.innerMostMBlock *= - linalgOp.getShape(linalgOp.getDpsInputOperand(0))[MDimTypeIdx[i]]; - } + for (auto &&[i, d] : llvm::enumerate(MDimTypeIdx)) + if (i != 0) + config.innerMostMBlock *= + linalgOp.getShape(linalgOp.getDpsInputOperand(0))[d]; givenInnermostBlock.push_back(config.innerMostMBlock); } else { givenInnermostBlock.push_back(0); } if (NDimTypeIdx.size() > 1) { config.innerMostNBlock = 1; - for (size_t i = 1UL; i < NDimTypeIdx.size(); i++) { - config.innerMostNBlock *= - linalgOp.getShape(linalgOp.getDpsInputOperand(1))[NDimTypeIdx[i]]; - } + for (auto &&[i, d] : llvm::enumerate(NDimTypeIdx)) + if (i != 0) + config.innerMostNBlock *= + linalgOp.getShape(linalgOp.getDpsInputOperand(1))[d]; givenInnermostBlock.push_back(config.innerMostNBlock); } else { givenInnermostBlock.push_back(0); } if (KDimTypeIdx.size() > 1) { config.innerMostKBlock = 1; - for (size_t i = 1UL; i < KDimTypeIdx.size(); i++) { - config.innerMostKBlock *= - linalgOp.getShape(linalgOp.getDpsInputOperand(1))[KDimTypeIdx[i]]; - } + for (auto &&[i, d] : llvm::enumerate(KDimTypeIdx)) + if (i != 0) + config.innerMostKBlock *= + linalgOp.getShape(linalgOp.getDpsInputOperand(1))[d]; givenInnermostBlock.push_back(config.innerMostKBlock); } else { givenInnermostBlock.push_back(0); @@ -444,13 +430,11 @@ MatmulConfigAnalysis::MatmulConfigAnalysis(Operation *root) { SmallVector shape = {M, N, K}; std::vector configCandidates = prepareConfigCandidates(root, sysDesc, shape, givenInnermostBlock); - for (auto &&[fn, name, threshold] : costModelList) { + for (auto &&[fn, name, threshold] : costModelList) configCandidates = filterConfigByCostModel( configCandidates, linalgOp, shape, sysDesc, fn, 0.5, threshold); - } - if (!configCandidates.empty()) { + if (!configCandidates.empty()) config = configCandidates[0]; - } } LLVM_DEBUG(llvm::dbgs() diff --git a/lib/gc/Transforms/DeepTileContractionNamedOp.cpp b/lib/gc/Transforms/DeepTileContractionNamedOp.cpp index d07797a94..4c0373646 100644 --- a/lib/gc/Transforms/DeepTileContractionNamedOp.cpp +++ b/lib/gc/Transforms/DeepTileContractionNamedOp.cpp @@ -44,9 +44,8 @@ tensorViewRankedTensor(RewriterBase &rewriter, RankedTensorType outTensorType, mlir::Type tensorElementType = inTensorType.getElementType(); // Check if the input and output tensor have the same shape - if (inShape == outShape) { + if (inShape == outShape) return currentValue; - } if (outShape.size() < inShape.size()) { SmallVector reassocIndices; @@ -93,9 +92,8 @@ tensorViewRankedTensor(RewriterBase &rewriter, RankedTensorType outTensorType, // Transpose the tensor if permutation is not empty if (!permutation.empty()) { SmallVector transposeShape; - for (int64_t idx : permutation) { + for (int64_t idx : permutation) transposeShape.push_back(outShape[idx]); - } Operation *initOp = rewriter.create(loc, transposeShape, tensorElementType); Operation *transposeOp = rewriter.create( @@ -110,9 +108,8 @@ bool isDummyLoop(LoopLikeOpInterface loop) { std::optional tripCount = mlir::constantTripCount( *loop.getSingleLowerBound(), *loop.getSingleUpperBound(), *loop.getSingleStep()); - if (tripCount) { + if (tripCount) return *tripCount == 1; - } return false; } @@ -132,9 +129,8 @@ static void buildLinalgRegion(Operation *op, bool createTemporaryOp = false) { if (createTemporaryOp) { unsigned argNum = body->getNumArguments(); SmallVector vals; - for (size_t i = initSize; i > 0; i--) { + for (size_t i = initSize; i > 0; i--) vals.push_back(body->getArgument(argNum - i)); - } OpBuilder::InsertionGuard g(b); b.setInsertionPointToEnd(body); Location loc = b.getUnknownLoc(); @@ -185,23 +181,21 @@ matmulDtypeLegalize(RewriterBase &rewriter, Operation *op, ShapedType initType = cast(initValue.getType()); ArrayRef tensorShape = initType.getShape(); SmallVector mixedShape; - for (size_t i = 0UL; i < tensorShape.size(); i++) { + for (auto &&[i, t] : llvm::enumerate(tensorShape)) { if (initType.isDynamicDim(i)) { Value val = rewriter.create(loc, initValue, i); mixedShape.push_back(val); } else { - mixedShape.push_back( - getAsIndexOpFoldResult(rewriter.getContext(), tensorShape[i])); + mixedShape.push_back(getAsIndexOpFoldResult(rewriter.getContext(), t)); } } Operation *currentOp; currentOp = rewriter.create( loc, mixedShape, Float32Type::get(op->getContext())); - if (needCopyInit) { + if (needCopyInit) currentOp = rewriter.create(loc, initOp->getResult(0), currentOp->getResult(0)); - } SmallVector newOperands = linalgOp->getOperands(); Value oldInit = newOperands.back(); newOperands.back() = currentOp->getResult(0); @@ -245,10 +239,8 @@ static Operation *findParentFillOp(Value val) { !isa(currentOp)) { currentOp = currentOp->getOperand(0).getDefiningOp(); } - if (currentOp && isa(currentOp)) { + if (currentOp && isa(currentOp)) return currentOp; - } - return nullptr; } @@ -262,12 +254,11 @@ static void getMatmulParallelDims(linalg::LinalgOp linalgOp, linalgOp.getIteratorTypesArray(); ArrayRef results = map.getResults(); - for (AffineExpr dim : results) { + for (const AffineExpr &dim : results) { AffineDimExpr dimExpr = dyn_cast(dim); if (dimExpr && iteratorTypes[dimExpr.getPosition()] == - mlir::utils::IteratorType::parallel) { + mlir::utils::IteratorType::parallel) dims.push_back(dimExpr.getPosition()); - } } } @@ -283,21 +274,19 @@ static void setStaticSizeForExtractSliceOp(RewriterBase &rewriter, SmallVector mixedOffsets = extractSlice.getMixedOffsets(); SmallVector mixedSizes = extractSlice.getMixedSizes(); SmallVector mixedStrides = extractSlice.getMixedStrides(); - for (size_t i = 0UL; i < mixedSizes.size(); i++) { - mixedSizes[i] = getAsIndexOpFoldResult(rewriter.getContext(), size[i]); - } - if (shrinDimNum > 0) { + for (auto &&[i, s] : llvm::enumerate(size)) + mixedSizes[i] = getAsIndexOpFoldResult(rewriter.getContext(), s); + if (shrinDimNum > 0) rewriter.replaceOpWithNewOp( extractSlice, mlir::RankedTensorType::get( SmallVector(size.begin() + shrinDimNum, size.end()), extractSlice.getResult().getType().getElementType()), extractSlice.getSource(), mixedOffsets, mixedSizes, mixedStrides); - } else { + else rewriter.replaceOpWithNewOp( extractSlice, extractSlice.getSource(), mixedOffsets, mixedSizes, mixedStrides); - } } } @@ -312,9 +301,8 @@ static void setStaticSizeForInsertSliceOp(RewriterBase &rewriter, Operation *op, SmallVector mixedOffsets = insertSlice.getMixedOffsets(); SmallVector mixedSizes = insertSlice.getMixedSizes(); SmallVector mixedStrides = insertSlice.getMixedStrides(); - for (size_t i = 0UL; i < mixedSizes.size(); i++) { - mixedSizes[i] = getAsIndexOpFoldResult(rewriter.getContext(), size[i]); - } + for (auto &&[i, s] : llvm::enumerate(size)) + mixedSizes[i] = getAsIndexOpFoldResult(rewriter.getContext(), s); rewriter.replaceOpWithNewOp( insertSlice, source, insertSlice.getDest(), mixedOffsets, mixedSizes, mixedStrides); @@ -360,11 +348,10 @@ generateOuterLoop(RewriterBase &b, linalg::LinalgOp linalgOp, linalgOp.getIteratorTypesArray(); if (loopType.size() != loopDim.size() || - loopDim.size() != nestedTileSizes.size()) { + loopDim.size() != nestedTileSizes.size()) return b.notifyMatchFailure( linalgOp, "loopType, loopDim and nestedTileSizes should have the same size"); - } if (linalgOp.hasPureBufferSemantics()) return b.notifyMatchFailure( @@ -376,7 +363,7 @@ generateOuterLoop(RewriterBase &b, linalg::LinalgOp linalgOp, ArrayRef currentDim = loopDim[i]; ArrayRef currentTileSize = nestedTileSizes[i]; if (loopType == OuterLoopGenerationOption::LoopType::ForOp) { - for (auto [d, tile] : llvm::zip(currentDim, currentTileSize)) { + for (auto &&[d, tile] : llvm::zip(currentDim, currentTileSize)) { scf::SCFTilingOptions tileOption; SmallVector TileSizes( currentOp.getNumLoops(), getAsIndexOpFoldResult(b.getContext(), 0)); @@ -390,9 +377,8 @@ generateOuterLoop(RewriterBase &b, linalg::LinalgOp linalgOp, for (const auto &fn : option.innermostFullResultCallBacks) { FailureOr result = fn(b, currentOp->getLoc(), currentOp); - if (succeeded(result)) { + if (succeeded(result)) currentOp = *result; - } } hasFullResult = false; } @@ -404,9 +390,8 @@ generateOuterLoop(RewriterBase &b, linalg::LinalgOp linalgOp, if (!isDummyLoop(tilingResult->loops.back())) { b.replaceOp(currentOp, tilingResult->replacements); currentOp = dyn_cast(tilingResult->tiledOps.back()); - if (iteratorTypes[d] == mlir::utils::IteratorType::reduction) { + if (iteratorTypes[d] == mlir::utils::IteratorType::reduction) result.reductionLoops.push_back(tilingResult->loops.back()); - } result.loops.push_back(tilingResult->loops.back()); } } @@ -423,32 +408,29 @@ generateOuterLoop(RewriterBase &b, linalg::LinalgOp linalgOp, for (auto &&[d, tile] : llvm::zip(currentDim, currentTileSize)) { if (llvm::find(reductionDims, d) != reductionDims.end() && tile != 0 && (!getConstantIntValue(loopRanges[d].size) || - tile != static_cast( - *getConstantIntValue(loopRanges[d].size)))) { + tile != + static_cast(*getConstantIntValue(loopRanges[d].size)))) tileOnReduction = true; - } if (llvm::find(reductionDims, d) != reductionDims.end() && !dyn_cast(currentOp.getOperation())) { tileSizes[d] = getAsIndexOpFoldResult(b.getContext(), 0); tileOnReduction = false; - } else + } else { tileSizes[d] = getAsIndexOpFoldResult(b.getContext(), tile); + } } OpBuilder::InsertionGuard guard(b); b.setInsertionPoint(currentOp); if (tileOnReduction) { - for (auto &&[idx, tile] : llvm::enumerate(tileSizes)) { + for (auto &&[idx, tile] : llvm::enumerate(tileSizes)) if (isConstantIntValue(tile, 0) && - llvm::find(reductionDims, idx) != reductionDims.end()) { + llvm::find(reductionDims, idx) != reductionDims.end()) tileSizes[idx] = loopRanges[idx].size; - } - } SmallVector newParallelDims; - for (auto iter : llvm::enumerate(reductionDims)) { + for (auto iter : llvm::enumerate(reductionDims)) newParallelDims.push_back( getAsIndexOpFoldResult(b.getContext(), iter.index())); - } FailureOr tilingResult = linalgX::tileReductionUsingForall( b, cast(currentOp.getOperation()), @@ -462,9 +444,8 @@ generateOuterLoop(RewriterBase &b, linalg::LinalgOp linalgOp, for (const auto &fn : option.finalReduceCallBacks) { FailureOr result = fn(b, currentOp->getLoc(), *tilingResult); - if (succeeded(result)) { + if (succeeded(result)) currentOp = *result; - } } } } else { @@ -623,7 +604,7 @@ struct DeepTileMatmul : public OpInterfaceRewritePattern { option.loopType.emplace_back(OuterLoopGenerationOption::LoopType::ForOp); option.loopDim.emplace_back(SmallVector{NDimPos.back()}); } - for (size_t dim = 0UL; dim < linalgOp.getNumLoops(); dim++) { + for (size_t dim = 0UL; dim < linalgOp.getNumLoops(); ++dim) { if (dim != MDimPos.back() && dim != NDimPos.back() && iteratorTypes[dim] != mlir::utils::IteratorType::reduction) { option.nestedTileSizes.emplace_back(SmallVector{1}); @@ -658,12 +639,11 @@ struct DeepTileMatmul : public OpInterfaceRewritePattern { -> FailureOr { ArrayRef initValue = result.initialValues; if (llvm::hasSingleElement(initValue) && - isa(initValue[0].getDefiningOp())) { + isa(initValue[0].getDefiningOp())) rewriter.replaceOp(initValue[0].getDefiningOp(), dyn_cast( initValue[0].getDefiningOp()) .getDpsInits()[0]); - } return dyn_cast(result.parallelTiledOps.back()); }; option.finalReduceCallBacks.push_back(removeReduncantFill); @@ -786,7 +766,7 @@ struct DeepTileMatmul : public OpInterfaceRewritePattern { setStaticSizeForExtractSliceOp(rewriter, currentOp.getDpsInputs()[0].getDefiningOp(), true, AInnermostDims, MDimNum > 1); - for (Value init : currentOp.getDpsInits()) { + for (const Value &init : currentOp.getDpsInits()) { setStaticSizeForExtractSliceOp(rewriter, init.getDefiningOp(), true, CInnermostDims, MDimNum > 1 ? 2 : 0); } @@ -823,21 +803,19 @@ struct DeepTileMatmul : public OpInterfaceRewritePattern { // Create the brgemm op and replace the origin linalg op linalg::LinalgOp matmul; if (dyn_cast(weightOprand.getType()).getShape().size() == - 3) { + 3) matmul = rewriter.create( loc, resultOprand.getType(), ValueRange{dataOprand, weightOprand}, resultOprand); - } else { + else matmul = rewriter.create( loc, resultOprand.getType(), ValueRange{dataOprand, weightOprand}, resultOprand); - } Value result = matmul.getOperation()->getResult(0); // Insert the result back to the original tensor - for (Operation *user : currentOp->getResult(0).getUsers()) { + for (Operation *user : currentOp->getResult(0).getUsers()) setStaticSizeForInsertSliceOp(rewriter, user, result, CInnermostDims); - } if (option.needLowPrecisionCast) { // fuse the low precision cast to the innermost body @@ -876,10 +854,9 @@ struct DeepTileMatmul : public OpInterfaceRewritePattern { rewriter.create(loc, currentOp.getDpsInits().back()); } // set static size for the insertSliceOp of copyOp - for (Operation *user : currentOp->getResult(1).getUsers()) { + for (Operation *user : currentOp->getResult(1).getUsers()) setStaticSizeForInsertSliceOp(rewriter, user, ifOp->getResult(0), CInnermostDims); - } rewriter.replaceOp(currentOp, {matmul->getResult(0), ifOp->getResult(0)}); } else { rewriter.replaceOp(currentOp, matmul->getResult(0)); @@ -889,7 +866,7 @@ struct DeepTileMatmul : public OpInterfaceRewritePattern { // Fuse the fill op to the innermost body if (auto fillOp = llvm::dyn_cast_or_null(option.fillOp)) { Value fillValue = fillOp.getDpsInputs()[0]; - if (cfg.KThreads <= 1) { + if (cfg.KThreads <= 1) // if use k slicing, the fill op is still need to be kept for the reduce // init rewriter.replaceUsesWithIf(fillOp.getResult(0), fillOp.getDpsInits()[0], @@ -897,7 +874,6 @@ struct DeepTileMatmul : public OpInterfaceRewritePattern { return isa( operand.getOwner()); }); - } rewriter.setInsertionPointAfter(currentOp); Value cond; @@ -983,18 +959,16 @@ struct DeepTileMatmul : public OpInterfaceRewritePattern { // Step 2. Outer loop generation FailureOr outerLoopResult = outerLoopGeneration( rewriter, linalgOp, cfg, fillOp && isa(fillOp)); - if (failed(outerLoopResult)) { + if (failed(outerLoopResult)) return failure(); - } linalgOp = dyn_cast(outerLoopResult->tiledOps.back()); // Step 3 generate inner loop body, convert the linalg.generic to brgemm innerBodyGenerationOption option = innerBodyGenerationOption{ fillOp, needLowPrecisionCast, outerLoopResult->reductionLoops}; - if (failed(innerBodyGeneration(rewriter, originOp, linalgOp, option))) { + if (failed(innerBodyGeneration(rewriter, originOp, linalgOp, option))) return failure(); - } rewriter.eraseOp(originOp); return success(); } @@ -1020,10 +994,9 @@ struct DeepTileContractionNamedOp dialect->getCanonicalizationPatterns(patterns); for (RegisteredOperationName op : ctx.getRegisteredOperations()) op.getCanonicalizationPatterns(patterns, &ctx); - if (failed(applyPatternsAndFoldGreedily(getOperation(), - std::move(patterns)))) { + if (failed( + applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)))) return signalPassFailure(); - } } }; diff --git a/lib/gc/Transforms/MergeNestedForall.cpp b/lib/gc/Transforms/MergeNestedForall.cpp index 516981c9c..07eb5ffbf 100644 --- a/lib/gc/Transforms/MergeNestedForall.cpp +++ b/lib/gc/Transforms/MergeNestedForall.cpp @@ -82,10 +82,9 @@ struct MergeNestedForall patterns.add(patterns.getContext()); - if (failed(applyPatternsAndFoldGreedily(getOperation(), - std::move(patterns)))) { + if (failed( + applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)))) return signalPassFailure(); - } } }; diff --git a/lib/gc/Transforms/SinkOpIntoInnerLoop.cpp b/lib/gc/Transforms/SinkOpIntoInnerLoop.cpp index df04b6590..965a26392 100644 --- a/lib/gc/Transforms/SinkOpIntoInnerLoop.cpp +++ b/lib/gc/Transforms/SinkOpIntoInnerLoop.cpp @@ -29,9 +29,8 @@ struct SinkOpIntoInnerLoop getOperation()->walk([&](LoopLikeOpInterface loop) { SmallVector regionsToSink; // Get the regions are that known to be executed at most once. - for (auto &it : loop->getRegions()) { + for (auto &it : loop->getRegions()) regionsToSink.push_back(&it); - } // Sink side-effect free operations. controlFlowSink( regionsToSink, domInfo,