[Mlir-commits] [mlir] [mlir][Interfaces] Add `mustProgress` interface method + folding pattern (PR #179039)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Jan 31 06:30:21 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-scf
Author: Matthias Springer (matthias-springer)
<details>
<summary>Changes</summary>
Add an interface method to the `RegionBranchOpInterface` to check if an operation "must progress". Add `mustProgress` attributes to `scf.for` and `scf.while` (default value is "true").
`mustProgress` corresponds to the [`llvm.loop.mustprogress` metadata](https://llvm.org/docs/LangRef.html#langref-llvm-loop-mustprogress).
Also add a canonicalization pattern to erase `RegionBranchOpInterface` ops that must progress but loop infinitely (and are non-side-effecting). This canonicalization pattern is enabled for `scf.for` and `scf.while`.
RFC: https://discourse.llvm.org/t/infinite-loops-and-dead-code/89530
---
Patch is 23.74 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/179039.diff
13 Files Affected:
- (modified) mlir/include/mlir/Dialect/SCF/IR/SCFOps.td (+11-6)
- (modified) mlir/include/mlir/Dialect/UB/IR/UBOps.h (+12)
- (modified) mlir/include/mlir/Interfaces/ControlFlowInterfaces.h (+12)
- (modified) mlir/include/mlir/Interfaces/ControlFlowInterfaces.td (+12)
- (modified) mlir/lib/Dialect/SCF/IR/CMakeLists.txt (+1)
- (modified) mlir/lib/Dialect/SCF/IR/SCF.cpp (+45-3)
- (modified) mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp (+3-2)
- (modified) mlir/lib/Dialect/UB/IR/CMakeLists.txt (+1)
- (modified) mlir/lib/Dialect/UB/IR/UBOps.cpp (+38)
- (modified) mlir/lib/Interfaces/ControlFlowInterfaces.cpp (+73-30)
- (modified) mlir/test/CAPI/ir.c (+1-1)
- (modified) mlir/test/Dialect/SCF/canonicalize.mlir (+51)
- (modified) mlir/test/Dialect/SCF/ops.mlir (+2-1)
``````````diff
diff --git a/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td b/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
index a08cf3c95e6ce..d1cbcb8352e36 100644
--- a/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
+++ b/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
@@ -40,7 +40,7 @@ def SCF_Dialect : Dialect {
and then lowered to some final target like LLVM or SPIR-V.
}];
- let dependentDialects = ["arith::ArithDialect"];
+ let dependentDialects = ["arith::ArithDialect", "ub::UBDialect"];
}
// Base class for SCF dialect ops.
@@ -160,7 +160,7 @@ def ForOp : SCF_Op<"for",
AllTypesMatch<["lowerBound", "upperBound", "step"]>,
ConditionallySpeculatable,
DeclareOpInterfaceMethods<RegionBranchOpInterface,
- ["getEntrySuccessorOperands", "getSuccessorInputs"]>,
+ ["getEntrySuccessorOperands", "getSuccessorInputs", "mustProgress"]>,
SingleBlockImplicitTerminator<"scf::YieldOp">,
RecursiveMemoryEffects]> {
let summary = "for operation";
@@ -265,7 +265,8 @@ def ForOp : SCF_Op<"for",
AnySignlessIntegerOrIndex:$upperBound,
AnySignlessIntegerOrIndex:$step,
Variadic<AnyType>:$initArgs,
- UnitAttr:$unsignedCmp);
+ UnitAttr:$unsignedCmp,
+ DefaultValuedAttr<BoolAttr, "true">:$mustProgress);
let results = (outs Variadic<AnyType>:$results);
let regions = (region SizedRegion<1>:$region);
@@ -983,7 +984,7 @@ def ReduceReturnOp :
def WhileOp : SCF_Op<"while",
[DeclareOpInterfaceMethods<RegionBranchOpInterface,
- ["getEntrySuccessorOperands", "getSuccessorInputs"]>,
+ ["getEntrySuccessorOperands", "getSuccessorInputs", "mustProgress"]>,
DeclareOpInterfaceMethods<LoopLikeOpInterface,
["getRegionIterArgs", "getYieldedValuesMutable"]>,
RecursiveMemoryEffects, SingleBlock]> {
@@ -1101,14 +1102,18 @@ def WhileOp : SCF_Op<"while",
```
}];
- let arguments = (ins Variadic<AnyType>:$inits);
+ let arguments = (ins Variadic<AnyType>:$inits,
+ DefaultValuedAttr<BoolAttr, "true">:$mustProgress);
let results = (outs Variadic<AnyType>:$results);
let regions = (region SizedRegion<1>:$before, SizedRegion<1>:$after);
+ let skipDefaultBuilders = 1;
let builders = [
OpBuilder<(ins "TypeRange":$resultTypes, "ValueRange":$inits,
"function_ref<void(OpBuilder &, Location, ValueRange)>":$beforeBuilder,
- "function_ref<void(OpBuilder &, Location, ValueRange)>":$afterBuilder)>
+ "function_ref<void(OpBuilder &, Location, ValueRange)>":$afterBuilder)>,
+ OpBuilder<(ins "TypeRange":$resultTypes, "ValueRange":$inits,
+ CArg<"bool", "true">:$mustProgress)>
];
let extraClassDeclaration = [{
diff --git a/mlir/include/mlir/Dialect/UB/IR/UBOps.h b/mlir/include/mlir/Dialect/UB/IR/UBOps.h
index 21de5cb0c182a..54a1d12737934 100644
--- a/mlir/include/mlir/Dialect/UB/IR/UBOps.h
+++ b/mlir/include/mlir/Dialect/UB/IR/UBOps.h
@@ -12,6 +12,7 @@
#include "mlir/Bytecode/BytecodeOpInterface.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpImplementation.h"
+#include "mlir/IR/PatternMatch.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Dialect/UB/IR/UBOpsInterfaces.h.inc"
@@ -24,4 +25,15 @@
#include "mlir/Dialect/UB/IR/UBOpsDialect.h.inc"
+namespace mlir {
+namespace ub {
+/// Populate a canonicalization pattern that erases "must progress" region
+/// branch ops that loop infinitely and replaces their results with poisoned
+/// values.
+void populateEraseInfiniteRegionBranchLoopPattern(RewritePatternSet &patterns,
+ StringRef opName,
+ PatternBenefit benefit = 1);
+} // namespace ub
+} // namespace mlir
+
#endif // MLIR_DIALECT_UB_IR_OPS_H
diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
index a76dce6f2ffc5..33e139f6b0cea 100644
--- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
+++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
@@ -314,6 +314,11 @@ Region *getEnclosingRepetitiveRegion(Operation *op);
/// exists.
Region *getEnclosingRepetitiveRegion(Value value);
+/// Return "true" if the given region branch op is guaranteed to loop
+/// infinitely. Every path starting from "parent" enters the region, but the
+/// "parent" is not reachable from there.
+bool isGuaranteedToLoopInfinitely(RegionBranchOpInterface op);
+
/// Populate canonicalization patterns that simplify successor operands/inputs
/// of region branch operations. Only operations with the given name are
/// matched.
@@ -359,6 +364,13 @@ void populateRegionBranchOpInterfaceInliningPattern(
PatternMatcherFn matcherFn = detail::defaultMatcherFn,
PatternBenefit benefit = 1);
+/// Return all successor regions when branching from the given region branch
+/// point. This helper functions extracts all constant operand values and
+/// passes them to the `RegionBranchOpInterface`.
+SmallVector<RegionSuccessor>
+getSuccessorRegionsWithAttrs(RegionBranchOpInterface op,
+ RegionBranchPoint point);
+
//===----------------------------------------------------------------------===//
// ControlFlow Traits
//===----------------------------------------------------------------------===//
diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td
index 8975b1235a7e3..49c2d564461bf 100644
--- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td
+++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td
@@ -351,6 +351,18 @@ def RegionBranchOpInterface : OpInterface<"RegionBranchOpInterface"> {
(ins "::mlir::Type":$lhs, "::mlir::Type":$rhs), [{}],
/*defaultImplementation=*/[{ return lhs == rhs; }]
>,
+ InterfaceMethod<[{
+ Region branch ops that "must progress" are required to terminate (i.e.,
+ not loop infinitely between their regions) or interact with the
+ environment in an observable way. If a "must progress" op is found to
+ loop infinitely without interacting with the environment, it may be
+ erased. See "llvm.loop.mustprogress" for more details.
+
+ Region branch ops must progress by default.
+ }],
+ "bool", "mustProgress", (ins), [{}],
+ /*defaultImplementation=*/[{ return true; }]
+ >
];
let verify = [{
diff --git a/mlir/lib/Dialect/SCF/IR/CMakeLists.txt b/mlir/lib/Dialect/SCF/IR/CMakeLists.txt
index b111117410ba3..a6b0626327cce 100644
--- a/mlir/lib/Dialect/SCF/IR/CMakeLists.txt
+++ b/mlir/lib/Dialect/SCF/IR/CMakeLists.txt
@@ -18,6 +18,7 @@ add_mlir_dialect_library(MLIRSCFDialect
MLIRLoopLikeInterface
MLIRSideEffectInterfaces
MLIRTensorDialect
+ MLIRUBDialect
MLIRValueBoundsOpInterface
MLIRTransformUtils
)
diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp
index c46a0577c4b96..6d8765f7de536 100644
--- a/mlir/lib/Dialect/SCF/IR/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp
@@ -16,6 +16,7 @@
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/DeviceMappingInterface.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "mlir/Dialect/UB/IR/UBOps.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/Matchers.h"
@@ -509,8 +510,10 @@ void ForOp::print(OpAsmPrinter &p) {
p.printRegion(getRegion(),
/*printEntryBlockArgs=*/false,
/*printBlockTerminators=*/!getInitArgs().empty());
- p.printOptionalAttrDict((*this)->getAttrs(),
- /*elidedAttrs=*/getUnsignedCmpAttrName().strref());
+ SmallVector<StringRef> elidedAttrs = {getUnsignedCmpAttrName().strref()};
+ if (getMustProgress()) // true is default, elide it
+ elidedAttrs.push_back(getMustProgressAttrName().strref());
+ p.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
}
ParseResult ForOp::parse(OpAsmParser &parser, OperationState &result) {
@@ -691,6 +694,24 @@ void ForOp::getSuccessorRegions(RegionBranchPoint point,
}
}
+ // Infinite loops (lb < ub and step size 0) enter the loop body and never
+ // leave it.
+ std::optional<std::pair<APInt, bool>> lbCst =
+ getConstantAPIntValue(getLowerBound());
+ std::optional<std::pair<APInt, bool>> ubCst =
+ getConstantAPIntValue(getUpperBound());
+ std::optional<std::pair<APInt, bool>> stepCst =
+ getConstantAPIntValue(getStep());
+ if (lbCst.has_value() && ubCst.has_value() && stepCst.has_value()) {
+ bool atLeastOneIteration =
+ (getUnsignedCmp() && lbCst->first.ult(ubCst->first)) ||
+ (!getUnsignedCmp() && lbCst->first.slt(ubCst->first));
+ if (atLeastOneIteration && stepCst->first.isZero()) {
+ regions.push_back(RegionSuccessor(&getRegion()));
+ return;
+ }
+ }
+
// Both the operation itself and the region may be branching into the body or
// back into the operation itself. It is possible for loop not to enter the
// body.
@@ -703,6 +724,8 @@ ValueRange ForOp::getSuccessorInputs(RegionSuccessor successor) {
: ValueRange(getRegionIterArgs());
}
+bool ForOp::mustProgress() { return getMustProgress(); }
+
SmallVector<Region *> ForallOp::getLoopRegions() { return {&getRegion()}; }
/// Promotes the loop body of a forallOp to its containing block if it can be
@@ -1004,6 +1027,8 @@ void ForOp::getCanonicalizationPatterns(RewritePatternSet &results,
auto forOp = cast<ForOp>(blockArg.getOwner()->getParentOp());
return forOp.getLowerBound();
});
+ ub::populateEraseInfiniteRegionBranchLoopPattern(results,
+ ForOp::getOperationName());
}
std::optional<APInt> ForOp::getConstantStep() {
@@ -3210,6 +3235,16 @@ void WhileOp::build(::mlir::OpBuilder &odsBuilder,
afterBuilder(odsBuilder, odsState.location, afterBlock->getArguments());
}
+void WhileOp::build(::mlir::OpBuilder &odsBuilder,
+ ::mlir::OperationState &odsState, TypeRange resultTypes,
+ ValueRange inits, bool mustProgress) {
+ odsState.addOperands(inits);
+ for (unsigned i = 0; i < 2; ++i)
+ (void)odsState.addRegion();
+ odsState.addTypes(resultTypes);
+ odsState.addAttribute("mustProgress", odsBuilder.getBoolAttr(mustProgress));
+}
+
ConditionOp WhileOp::getConditionOp() {
return cast<ConditionOp>(getBeforeBody()->getTerminator());
}
@@ -3273,6 +3308,8 @@ ValueRange WhileOp::getSuccessorInputs(RegionSuccessor successor) {
llvm_unreachable("invalid region successor");
}
+bool WhileOp::mustProgress() { return getMustProgress(); }
+
SmallVector<Region *> WhileOp::getLoopRegions() {
return {&getBefore(), &getAfter()};
}
@@ -3332,7 +3369,10 @@ void scf::WhileOp::print(OpAsmPrinter &p) {
p.printRegion(getBefore(), /*printEntryBlockArgs=*/false);
p << " do ";
p.printRegion(getAfter());
- p.printOptionalAttrDictWithKeyword((*this)->getAttrs());
+ SmallVector<StringRef> elidedAttrs;
+ if (getMustProgress()) // true is default, elide it
+ elidedAttrs.push_back(getMustProgressAttrName().strref());
+ p.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs);
}
/// Verifies that two ranges of types match, i.e. have the same number of
@@ -3708,6 +3748,8 @@ void WhileOp::getCanonicalizationPatterns(RewritePatternSet &results,
results, WhileOp::getOperationName());
populateRegionBranchOpInterfaceInliningPattern(results,
WhileOp::getOperationName());
+ ub::populateEraseInfiniteRegionBranchLoopPattern(results,
+ WhileOp::getOperationName());
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp b/mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp
index ddcbda86cf1f3..152fb226993e9 100644
--- a/mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp
@@ -49,8 +49,9 @@ struct ForLoopLoweringPattern : public OpRewritePattern<ForOp> {
SmallVector<Value> initArgs;
initArgs.push_back(forOp.getLowerBound());
llvm::append_range(initArgs, forOp.getInitArgs());
- auto whileOp = WhileOp::create(rewriter, forOp.getLoc(), lcvTypes, initArgs,
- forOp->getAttrs());
+ auto whileOp =
+ WhileOp::create(rewriter, forOp.getLoc(), lcvTypes, initArgs);
+ whileOp->setAttrs(forOp->getAttrDictionary());
// 'before' region contains the loop condition and forwarding of iteration
// arguments to the 'after' region.
diff --git a/mlir/lib/Dialect/UB/IR/CMakeLists.txt b/mlir/lib/Dialect/UB/IR/CMakeLists.txt
index 84125ea0b5718..d96a552dce5f0 100644
--- a/mlir/lib/Dialect/UB/IR/CMakeLists.txt
+++ b/mlir/lib/Dialect/UB/IR/CMakeLists.txt
@@ -5,6 +5,7 @@ add_mlir_dialect_library(MLIRUBDialect
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/UB
DEPENDS
+ MLIRControlFlowInterfaces
MLIRUBOpsIncGen
MLIRUBOpsInterfacesIncGen
diff --git a/mlir/lib/Dialect/UB/IR/UBOps.cpp b/mlir/lib/Dialect/UB/IR/UBOps.cpp
index ee523f9522953..391c2aef7ef15 100644
--- a/mlir/lib/Dialect/UB/IR/UBOps.cpp
+++ b/mlir/lib/Dialect/UB/IR/UBOps.cpp
@@ -8,6 +8,7 @@
#include "mlir/Dialect/UB/IR/UBOps.h"
#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
+#include "mlir/Interfaces/ControlFlowInterfaces.h"
#include "mlir/Transforms/InliningUtils.h"
#include "mlir/IR/Builders.h"
@@ -66,3 +67,40 @@ OpFoldResult PoisonOp::fold(FoldAdaptor /*adaptor*/) { return getValue(); }
#define GET_OP_CLASSES
#include "mlir/Dialect/UB/IR/UBOps.cpp.inc"
+
+namespace {
+/// Canonicalization pattern for RegionBranchOpInterface ops that loop
+/// infinitely. Such ops are replaced with poisoned values if they "must
+/// progress".
+struct EraseInfiniteRegionBranchLoop : public RewritePattern {
+ EraseInfiniteRegionBranchLoop(MLIRContext *context, StringRef name,
+ PatternBenefit benefit = 1)
+ : RewritePattern(name, benefit, context) {}
+
+ LogicalResult matchAndRewrite(Operation *op,
+ PatternRewriter &rewriter) const override {
+ auto regionBranchOp = cast<RegionBranchOpInterface>(op);
+ if (!regionBranchOp.mustProgress())
+ return rewriter.notifyMatchFailure(
+ op, "only loops that must progress are removed");
+ if (!wouldOpBeTriviallyDead(op))
+ return rewriter.notifyMatchFailure(op,
+ "only trivially dead ops are removed");
+ if (!isGuaranteedToLoopInfinitely(regionBranchOp))
+ return rewriter.notifyMatchFailure(
+ op, "only loops that loop infinitely are removed");
+ SmallVector<Value> replacements =
+ llvm::map_to_vector(op->getResultTypes(), [&](Type type) {
+ return PoisonOp::create(rewriter, op->getLoc(), type).getResult();
+ });
+ rewriter.replaceOp(op, replacements);
+ return success();
+ }
+};
+} // namespace
+
+void mlir::ub::populateEraseInfiniteRegionBranchLoopPattern(
+ RewritePatternSet &patterns, StringRef opName, PatternBenefit benefit) {
+ patterns.add<EraseInfiniteRegionBranchLoop>(patterns.getContext(), opName,
+ benefit);
+}
diff --git a/mlir/lib/Interfaces/ControlFlowInterfaces.cpp b/mlir/lib/Interfaces/ControlFlowInterfaces.cpp
index 2f95531455b2b..873685368d996 100644
--- a/mlir/lib/Interfaces/ControlFlowInterfaces.cpp
+++ b/mlir/lib/Interfaces/ControlFlowInterfaces.cpp
@@ -577,6 +577,49 @@ Region *mlir::getEnclosingRepetitiveRegion(Value value) {
return nullptr;
}
+/// Return "true" if the given region branch op is guaranteed to loop
+/// infinitely. Every path starting from "parent" enters the region, but the
+/// "parent" is not reachable from there.
+bool mlir::isGuaranteedToLoopInfinitely(RegionBranchOpInterface op) {
+ llvm::SmallDenseSet<Region *> visited;
+
+ // Path starts with "parent".
+ SmallVector<RegionBranchPoint> worklist;
+ worklist.push_back(RegionBranchPoint::parent());
+ bool enteredRegion = false;
+ while (!worklist.empty()) {
+ RegionBranchPoint next = worklist.pop_back_val();
+ SmallVector<RegionSuccessor> successors =
+ getSuccessorRegionsWithAttrs(op, next);
+ for (RegionSuccessor successor : successors) {
+ if (successor.isParent()) {
+ // Found path that ends with "parent".
+ return false;
+ }
+ enteredRegion = true;
+ Region *region = successor.getSuccessor();
+ if (!visited.insert(region).second) {
+ // We have already visited this region.
+ continue;
+ }
+ for (Block &block : *region) {
+ auto terminator =
+ dyn_cast<RegionBranchTerminatorOpInterface>(block.back());
+ if (!terminator) {
+ // Region has no RegionBranchTerminatorOpInterface terminator. E.g.,
+ // the terminator could be a "ub.unreachable" op or a "cf.br" op.
+ continue;
+ }
+ worklist.push_back(RegionBranchPoint(terminator));
+ }
+ }
+ }
+ // We visited all paths through the region branch op and the parent was not
+ // reached. If we visited at least one region, it means that we got stuck
+ // inside the region branch op, indicating an infinite loop.
+ return enteredRegion;
+}
+
/// Return "true" if `a` can be used in lieu of `b`, where `b` is a region
/// successor input and `a` is a "reachable value" of `b`. Reachable values
/// are successor operand values that are (maybe transitively) forwarded to
@@ -679,6 +722,36 @@ static llvm::SmallDenseSet<Value> computeReachableValuesFromSuccessorInput(
return reachableValues;
}
+/// Given a range of values, return a vector of attributes of the same size,
+/// where the i-th attribute is the constant value of the i-th value. If a
+/// value is not constant, the corresponding attribute is null.
+static SmallVector<Attribute> extractConstants(ValueRange values) {
+ return llvm::map_to_vector(values, [](Value value) {
+ Attribute attr;
+ matchPattern(value, m_Constant(&attr));
+ return attr;
+ });
+}
+
+/// Return all successor regions when branching from the given region branch
+/// point. This helper functions extracts all constant operand values and
+/// passes them to the `RegionBranchOpInterface`.
+SmallVector<RegionSuccessor>
+mlir::getSuccessorRegionsWithAttrs(RegionBranchOpInterface op,
+ RegionBranchPoint point) {
+ SmallVector<RegionSuccessor> successors;
+ if (point.isParent()) {
+ op.getEntrySuccessorRegions(extractConstants(op->getOperands()),
+ successors);
+ return successors;
+ }
+ RegionBranchTerminatorOpInterface terminator =
+ point.getTerminatorPredecessorOrNull();
+ terminator.getSuccessorRegions(extractConstants(terminator->getOperands()),
+ successors);
+ return successors;
+}
+
namespace {
/// Try to make successor inputs dead by replacing their uses with values that
/// are not successor inputs. This pattern enables additional canonicalization
@@ -1045,36 +1118,6 @@ struct RemoveDuplicateSuccessorInputUses : public RewritePattern {
}
};
-/// Given a range of values, return a vector of attributes of the same size,
-/// where the i-th attribute is the constant value of the i-th value. If a
-/// value is not constant, the corresponding attribute is null.
-static SmallVector<Attribute> extractConstants(ValueRange values) {
- return llvm::map_to_vector(values, [](Value value) {
- Attribute attr;
- matchPattern(value, m_Constant(&attr));
- return attr;
- });
-}
-
-/// Return all successor regions when branching from the given region branch
-/// point. This helper functions extracts all constant operand values and
-/// passes them to the `RegionBranchOpInterface`.
-static SmallVector<RegionSuccessor>
-getSuccessorRegionsWithAttrs(RegionBranchOpInterface op,
- RegionBranchPoint point) {
- SmallVector<RegionSuccessor> successors;
- if (point.isParent()) {
- op.getEntrySuccessorRegions(extractConstants(op->getOperands()),
- successor...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/179039
More information about the Mlir-commits
mailing list