[Mlir-commits] [mlir] [MLIR][Conversion] PDLToPDLInterp: Don't shadow maximum depth position when creating constraint position. (PR #162265)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Oct 7 04:55:43 PDT 2025


https://github.com/jumerckx updated https://github.com/llvm/llvm-project/pull/162265

>From f625ff78242e100292c12b83592b000d9e2768f9 Mon Sep 17 00:00:00 2001
From: jumerckx <31353884+jumerckx at users.noreply.github.com>
Date: Tue, 7 Oct 2025 13:31:57 +0200
Subject: [PATCH 1/2] don't shadow maximum depth position when creating
 constraint position.

---
 mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
index 39d4815dc73b7..f19536261f077 100644
--- a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
+++ b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
@@ -279,8 +279,8 @@ static void getConstraintPredicates(pdl::ApplyNativeConstraintOp op,
   // For each result register a position so it can be used later
   for (auto [i, result] : llvm::enumerate(results)) {
     ConstraintQuestion *q = cast<ConstraintQuestion>(pred.first);
-    ConstraintPosition *pos = builder.getConstraintPosition(q, i);
-    auto [it, inserted] = inputs.try_emplace(result, pos);
+    ConstraintPosition *constraintPos = builder.getConstraintPosition(q, i);
+    auto [it, inserted] = inputs.try_emplace(result, constraintPos);
     // If this is an input value that has been visited in the tree, add a
     // constraint to ensure that both instances refer to the same value.
     if (!inserted) {

>From 422f2c6e12847ff2914f24e228cf5c42b1f9c993 Mon Sep 17 00:00:00 2001
From: jumerckx <31353884+jumerckx at users.noreply.github.com>
Date: Tue, 7 Oct 2025 13:55:35 +0200
Subject: [PATCH 2/2] fix

---
 mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
index f19536261f077..e95a178c030d4 100644
--- a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
+++ b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
@@ -284,9 +284,9 @@ static void getConstraintPredicates(pdl::ApplyNativeConstraintOp op,
     // If this is an input value that has been visited in the tree, add a
     // constraint to ensure that both instances refer to the same value.
     if (!inserted) {
-      Position *first = pos;
+      Position *first = constraintPos;
       Position *second = it->second;
-      if (comparePosDepth(second, first))
+      if (comparePosDepth(second, pos))
         std::tie(second, first) = std::make_pair(first, second);
 
       predList.emplace_back(second, builder.getEqualTo(first));



More information about the Mlir-commits mailing list