@@ -141,6 +141,8 @@ class ConstraintInfo {
141141 getCS (Signed).popLastNVariables (N);
142142 }
143143
144+ bool doesHold (CmpInst::Predicate Pred, Value *A, Value *B) const ;
145+
144146 void addFact (CmpInst *Condition, bool IsNegated, unsigned NumIn,
145147 unsigned NumOut, SmallVectorImpl<StackEntry> &DFSInStack);
146148
@@ -364,16 +366,24 @@ ConstraintInfo::getConstraint(CmpInst::Predicate Pred, Value *Op0, Value *Op1,
364366bool ConstraintTy::isValid (const ConstraintInfo &Info) const {
365367 return Coefficients.size () > 0 &&
366368 all_of (Preconditions, [&Info](const PreconditionTy &C) {
367- DenseMap<Value *, unsigned > NewIndices;
368- auto R = Info.getConstraint (C.Pred , C.Op0 , C.Op1 , NewIndices);
369- // TODO: properly check NewIndices.
370- return NewIndices.empty () && R.Preconditions .empty () && !R.IsEq &&
371- R.size () >= 1 &&
372- Info.getCS (CmpInst::isSigned (C.Pred ))
373- .isConditionImplied (R.Coefficients );
369+ return Info.doesHold (C.Pred , C.Op0 , C.Op1 );
374370 });
375371}
376372
373+ bool ConstraintInfo::doesHold (CmpInst::Predicate Pred, Value *A,
374+ Value *B) const {
375+ DenseMap<Value *, unsigned > NewIndices;
376+ auto R = getConstraint (Pred, A, B, NewIndices);
377+
378+ if (!NewIndices.empty ())
379+ return false ;
380+
381+ // TODO: properly check NewIndices.
382+ return NewIndices.empty () && R.Preconditions .empty () && !R.IsEq &&
383+ !R.empty () &&
384+ getCS (CmpInst::isSigned (Pred)).isConditionImplied (R.Coefficients );
385+ }
386+
377387namespace {
378388// / Represents either a condition that holds on entry to a block or a basic
379389// / block, with their respective Dominator DFS in and out numbers.
0 commit comments