[llvm] [ConstraintElim] Link values to decompositions during queries if needed. (PR #224623)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 22 03:19:19 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);
----------------
fhahn wrote:
Yes that's a good point. It could benefit `doesHold` as well. I am not sure about integrating into `getConstraint` directly, as constructing the link row is not free (we need to decompose again, which trigger more queries).
Perhaps we can share the re-try logic with `doesHold` though. I'll check if I can find cases in practice and do this as follow-up
https://github.com/llvm/llvm-project/pull/224623
More information about the llvm-commits
mailing list