@@ -141,6 +141,8 @@ class ConstraintInfo {
141
141
getCS (Signed).popLastNVariables (N);
142
142
}
143
143
144
+ bool doesHold (CmpInst::Predicate Pred, Value *A, Value *B) const ;
145
+
144
146
void addFact (CmpInst *Condition, bool IsNegated, unsigned NumIn,
145
147
unsigned NumOut, SmallVectorImpl<StackEntry> &DFSInStack);
146
148
@@ -364,16 +366,24 @@ ConstraintInfo::getConstraint(CmpInst::Predicate Pred, Value *Op0, Value *Op1,
364
366
bool ConstraintTy::isValid (const ConstraintInfo &Info) const {
365
367
return Coefficients.size () > 0 &&
366
368
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 );
374
370
});
375
371
}
376
372
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
+
377
387
namespace {
378
388
// / Represents either a condition that holds on entry to a block or a basic
379
389
// / block, with their respective Dominator DFS in and out numbers.
0 commit comments