[llvm] [ConstraintElim] Link values to decompositions during queries if needed. (PR #224623)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 07:24:10 PDT 2026


================
@@ -1812,9 +1833,39 @@ static std::optional<bool> checkCondition(CmpInst::Predicate Pred, Value *A,
     return std::nullopt;
   };
 
+  // Retry the query after adding additional facts for A == decompose(A) and B
+  // == decompose(B), if needed.
+  auto TryWithLinkedDecomposition =
+      [&](const ConstraintTy &C) -> std::optional<bool> {
+    if (C.empty())
+      return std::nullopt;
+
+    auto &CS = Info.getCS(C.IsSigned);
+    unsigned NumVars = Info.getValue2Index(C.IsSigned).size();
+    unsigned NumPushed = 0;
+    for (Value *V : {A, B}) {
+      RowTy Row =
+          getDecompositionLinkRow(V, C, Info, CheckInst->getDataLayout());
+      RowTy Negated = ConstraintSystem::negateOrEqual(Row);
+      if (Row.empty() || Negated.empty())
+        continue;
+      NumPushed += CS.addRow(Row, NumVars);
+      NumPushed += CS.addRow(Negated, NumVars);
----------------
antoniofrighetto wrote:

I have been thinking whether it could make sense to have getConstraint() produce the link rows, and whether doesHold(), which may decompose a query too (if I'm following correctly), could also benefit from having this (via getConstraint()).

https://github.com/llvm/llvm-project/pull/224623


More information about the llvm-commits mailing list