[llvm] ConstraintSystem: replace data structure with Matrix (PR #98895)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 17 09:27:08 PDT 2024
================
@@ -1725,6 +1786,74 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
return A.NumIn < B.NumIn;
});
+ for (const FactOrCheck &CB : S.WorkList) {
+ ICmpInst::Predicate Pred;
+ Value *A, *B;
+ if (CB.isCheck()) {
+ if (auto *Cmp = dyn_cast<ICmpInst>(CB.getInstructionToSimplify())) {
+ if (!checkCondition(Cmp->getPredicate(), Cmp->getOperand(0),
+ Cmp->getOperand(1), Cmp, Info) &&
+ match(CB.getContextInst(), m_LogicalOp(m_Value(), m_Value()))) {
+ match(Cmp, m_ICmp(Pred, m_Value(A), m_Value(B)));
+ EstimatedColumns += getNumNewVars(Pred, A, B, Info, SeenVars);
+ }
+ }
+ continue;
+ }
+ if (!CB.isConditionFact()) {
+ Value *X;
+ if (match(CB.Inst, m_Intrinsic<Intrinsic::abs>(m_Value(X)))) {
+ if (cast<ConstantInt>(CB.Inst->getOperand(1))->isOne())
+ EstimatedColumns += getNumNewVars(
+ CmpInst::ICMP_SGE, CB.Inst,
+ ConstantInt::get(CB.Inst->getType(), 0), Info, SeenVars);
+ EstimatedColumns +=
+ getNumNewVars(CmpInst::ICMP_SGE, CB.Inst, X, Info, SeenVars);
+ continue;
+ }
+
+ if (auto *MinMax = dyn_cast<MinMaxIntrinsic>(CB.Inst)) {
+ Pred = ICmpInst::getNonStrictPredicate(MinMax->getPredicate());
+ EstimatedColumns +=
+ getNumNewVars(Pred, MinMax, MinMax->getLHS(), Info, SeenVars);
+ EstimatedColumns +=
+ getNumNewVars(Pred, MinMax, MinMax->getRHS(), Info, SeenVars);
+ continue;
+ }
+ }
+
+ if (CB.isConditionFact()) {
+ Pred = CB.Cond.Pred;
+ A = CB.Cond.Op0;
+ B = CB.Cond.Op1;
+ } else {
+ match(CB.Inst, m_Intrinsic<Intrinsic::assume>(
+ m_ICmp(Pred, m_Value(A), m_Value(B))));
+ }
+ EstimatedColumns += getNumNewVars(Pred, A, B, Info, SeenVars);
+ }
+ return {S, EstimatedColumns};
+}
+
+static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
+ ScalarEvolution &SE,
+ OptimizationRemarkEmitter &ORE) {
+ bool Changed = false;
+ DT.updateDFSNumbers();
+ SmallVector<Value *> FunctionArgs;
+ for (Value &Arg : F.args())
+ FunctionArgs.push_back(&Arg);
+ auto [S, EstimatedColumns] = dryRun(F, DT, LI, SE);
----------------
artagnon wrote:
I've used a `const_cast` on CB when passed to `checkOrAndOpImpliedByOther`. Let me know if this is what you meant.
https://github.com/llvm/llvm-project/pull/98895
More information about the llvm-commits
mailing list