@@ -142,8 +142,9 @@ class ConstraintInfo {
142
142
143
143
bool doesHold (CmpInst::Predicate Pred, Value *A, Value *B) const ;
144
144
145
- void addFact (CmpInst *Condition, bool IsNegated, unsigned NumIn,
146
- unsigned NumOut, SmallVectorImpl<StackEntry> &DFSInStack);
145
+ void addFact (CmpInst::Predicate Pred, Value *A, Value *B, bool IsNegated,
146
+ unsigned NumIn, unsigned NumOut,
147
+ SmallVectorImpl<StackEntry> &DFSInStack);
147
148
148
149
// / Turn a comparison of the form \p Op0 \p Pred \p Op1 into a vector of
149
150
// / constraints, using indices from the corresponding constraint system.
@@ -526,19 +527,19 @@ void State::addInfoFor(BasicBlock &BB) {
526
527
WorkList.emplace_back (DT.getNode (Br->getSuccessor (1 )), CmpI, true );
527
528
}
528
529
529
- void ConstraintInfo::addFact (CmpInst *Condition, bool IsNegated, unsigned NumIn ,
530
- unsigned NumOut,
530
+ void ConstraintInfo::addFact (CmpInst::Predicate Pred, Value *A, Value *B ,
531
+ bool IsNegated, unsigned NumIn, unsigned NumOut,
531
532
SmallVectorImpl<StackEntry> &DFSInStack) {
532
533
// If the constraint has a pre-condition, skip the constraint if it does not
533
534
// hold.
534
535
DenseMap<Value *, unsigned > NewIndices;
535
- auto R = getConstraint (Condition , NewIndices);
536
+ auto R = getConstraint (Pred, A, B , NewIndices);
536
537
if (!R.isValid (*this ))
537
538
return ;
538
539
539
- LLVM_DEBUG (dbgs () << " Adding " << *Condition << " " << IsNegated << " \n " );
540
+ // LLVM_DEBUG(dbgs() << "Adding " << *Condition << " " << IsNegated << "\n");
540
541
bool Added = false ;
541
- assert (CmpInst::isSigned (Condition-> getPredicate () ) == R.IsSigned &&
542
+ assert (CmpInst::isSigned (Pred ) == R.IsSigned &&
542
543
" condition and constraint signs must match" );
543
544
auto &CSToUse = getCS (R.IsSigned );
544
545
if (R.Coefficients .empty ())
@@ -759,9 +760,13 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT) {
759
760
}
760
761
}
761
762
762
- // Otherwise, add the condition to the system and stack, if we can transform
763
- // it into a constraint.
764
- Info.addFact (CB.Condition , CB.Not , CB.NumIn , CB.NumOut , DFSInStack);
763
+ ICmpInst::Predicate Pred;
764
+ Value *A, *B;
765
+ if (match (CB.Condition , m_ICmp (Pred, m_Value (A), m_Value (B)))) {
766
+ // Otherwise, add the condition to the system and stack, if we can
767
+ // transform it into a constraint.
768
+ Info.addFact (Pred, A, B, CB.Not , CB.NumIn , CB.NumOut , DFSInStack);
769
+ }
765
770
}
766
771
767
772
#ifndef NDEBUG
0 commit comments