Skip to content

Commit 6214496

Browse files
committed
[ConstraintElim] Add debug output for failed preconditions
Print debug output if a constraint does not get added due to a failed precondition.
1 parent 4de971c commit 6214496

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

llvm/lib/Transforms/Scalar/ConstraintElimination.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,15 +1642,14 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
16421642
DFSInStack);
16431643
}
16441644

1645-
LLVM_DEBUG(dbgs() << "Processing ");
1646-
16471645
// For a block, check if any CmpInsts become known based on the current set
16481646
// of constraints.
16491647
if (CB.isCheck()) {
16501648
Instruction *Inst = CB.getInstructionToSimplify();
16511649
if (!Inst)
16521650
continue;
1653-
LLVM_DEBUG(dbgs() << "condition to simplify: " << *Inst << "\n");
1651+
LLVM_DEBUG(dbgs() << "Processing condition to simplify: " << *Inst
1652+
<< "\n");
16541653
if (auto *II = dyn_cast<WithOverflowInst>(Inst)) {
16551654
Changed |= tryToSimplifyOverflowMath(II, Info, ToRemove);
16561655
} else if (auto *Cmp = dyn_cast<ICmpInst>(Inst)) {
@@ -1669,7 +1668,7 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
16691668
}
16701669

16711670
auto AddFact = [&](CmpInst::Predicate Pred, Value *A, Value *B) {
1672-
LLVM_DEBUG(dbgs() << "fact to add to the system: ";
1671+
LLVM_DEBUG(dbgs() << "Processing fact to add to the system: ";
16731672
dumpUnpackedICmp(dbgs(), Pred, A, B); dbgs() << "\n");
16741673
if (Info.getCS(CmpInst::isSigned(Pred)).size() > MaxRows) {
16751674
LLVM_DEBUG(
@@ -1718,8 +1717,17 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
17181717
A = CB.Cond.Op0;
17191718
B = CB.Cond.Op1;
17201719
if (CB.DoesHold.Pred != CmpInst::BAD_ICMP_PREDICATE &&
1721-
!Info.doesHold(CB.DoesHold.Pred, CB.DoesHold.Op0, CB.DoesHold.Op1))
1720+
!Info.doesHold(CB.DoesHold.Pred, CB.DoesHold.Op0, CB.DoesHold.Op1)) {
1721+
LLVM_DEBUG({
1722+
dbgs() << "Not adding fact ";
1723+
dumpUnpackedICmp(dbgs(), Pred, A, B);
1724+
dbgs() << " because precondition ";
1725+
dumpUnpackedICmp(dbgs(), CB.DoesHold.Pred, CB.DoesHold.Op0,
1726+
CB.DoesHold.Op1);
1727+
dbgs() << " does not hold.\n";
1728+
});
17221729
continue;
1730+
}
17231731
} else {
17241732
bool Matched = match(CB.Inst, m_Intrinsic<Intrinsic::assume>(
17251733
m_ICmp(Pred, m_Value(A), m_Value(B))));

0 commit comments

Comments
 (0)