[Mlir-commits] [mlir] [MLIR][SCF] Speed up ConditionPropagation (PR #166080)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Mon Nov 3 01:05:21 PST 2025
================
@@ -2565,6 +2565,38 @@ struct ConvertTrivialIfToSelect : public OpRewritePattern<IfOp> {
struct ConditionPropagation : public OpRewritePattern<IfOp> {
using OpRewritePattern<IfOp>::OpRewritePattern;
+ enum class Parent { Then, Else, None };
+
+ static Parent getParentType(Region *toCheck, IfOp op,
+ DenseMap<Region *, Parent> &cache) {
+ SmallVector<Region *> seen;
+ while (toCheck) {
+ auto found = cache.find(toCheck);
+ if (found != cache.end()) {
+ return found->second;
+ }
+ seen.push_back(toCheck);
+ if (&op.getThenRegion() == toCheck) {
+ for (auto v : seen) {
+ cache[v] = Parent::Then;
+ }
----------------
ftynse wrote:
```suggestion
for (Region *region : seen)
cache[region] = Parent::Then;
```
https://github.com/llvm/llvm-project/pull/166080
More information about the Mlir-commits
mailing list