@@ -216,7 +216,7 @@ struct StackEntry {
216
216
StackEntry (unsigned NumIn, unsigned NumOut, bool IsSigned,
217
217
SmallVector<Value *, 2 > ValuesToRelease)
218
218
: NumIn(NumIn), NumOut(NumOut), IsSigned(IsSigned),
219
- ValuesToRelease (ValuesToRelease) {}
219
+ ValuesToRelease (std::move( ValuesToRelease) ) {}
220
220
};
221
221
222
222
struct ConstraintTy {
@@ -726,8 +726,8 @@ ConstraintInfo::getConstraint(CmpInst::Predicate Pred, Value *Op0, Value *Op1,
726
726
}
727
727
728
728
for (const auto &KV : VariablesB) {
729
- if ( SubOverflow ( R[GetOrAddIndex (KV.Variable )], KV. Coefficient ,
730
- R[ GetOrAddIndex ( KV.Variable )] ))
729
+ auto &Coeff = R[GetOrAddIndex (KV.Variable )];
730
+ if ( SubOverflow (Coeff, KV.Coefficient , Coeff ))
731
731
return {};
732
732
auto I =
733
733
KnownNonNegativeVariables.insert ({KV.Variable , KV.IsKnownNonNegative });
@@ -759,9 +759,9 @@ ConstraintInfo::getConstraint(CmpInst::Predicate Pred, Value *Op0, Value *Op1,
759
759
if (!KV.second ||
760
760
(!Value2Index.contains (KV.first ) && !NewIndexMap.contains (KV.first )))
761
761
continue ;
762
- SmallVector<int64_t , 8 > C (Value2Index.size () + NewVariables.size () + 1 , 0 );
762
+ auto &C = Res.ExtraInfo .emplace_back (
763
+ Value2Index.size () + NewVariables.size () + 1 , 0 );
763
764
C[GetOrAddIndex (KV.first )] = -1 ;
764
- Res.ExtraInfo .push_back (C);
765
765
}
766
766
return Res;
767
767
}
@@ -1591,53 +1591,52 @@ void ConstraintInfo::addFact(CmpInst::Predicate Pred, Value *A, Value *B,
1591
1591
1592
1592
LLVM_DEBUG (dbgs () << " Adding '" ; dumpUnpackedICmp (dbgs (), Pred, A, B);
1593
1593
dbgs () << " '\n " );
1594
- bool Added = false ;
1595
1594
auto &CSToUse = getCS (R.IsSigned );
1596
1595
if (R.Coefficients .empty ())
1597
1596
return ;
1598
1597
1599
- Added |= CSToUse.addVariableRowFill (R.Coefficients );
1598
+ bool Added = CSToUse.addVariableRowFill (R.Coefficients );
1599
+ if (!Added)
1600
+ return ;
1600
1601
1601
1602
// If R has been added to the system, add the new variables and queue it for
1602
1603
// removal once it goes out-of-scope.
1603
- if (Added) {
1604
- SmallVector<Value *, 2 > ValuesToRelease;
1605
- auto &Value2Index = getValue2Index (R.IsSigned );
1606
- for (Value *V : NewVariables) {
1607
- Value2Index.insert ({V, Value2Index.size () + 1 });
1608
- ValuesToRelease.push_back (V);
1609
- }
1610
-
1611
- LLVM_DEBUG ({
1612
- dbgs () << " constraint: " ;
1613
- dumpConstraint (R.Coefficients , getValue2Index (R.IsSigned ));
1614
- dbgs () << " \n " ;
1615
- });
1604
+ SmallVector<Value *, 2 > ValuesToRelease;
1605
+ auto &Value2Index = getValue2Index (R.IsSigned );
1606
+ for (Value *V : NewVariables) {
1607
+ Value2Index.insert ({V, Value2Index.size () + 1 });
1608
+ ValuesToRelease.push_back (V);
1609
+ }
1616
1610
1617
- DFSInStack.emplace_back (NumIn, NumOut, R.IsSigned ,
1618
- std::move (ValuesToRelease));
1619
-
1620
- if (!R.IsSigned ) {
1621
- for (Value *V : NewVariables) {
1622
- ConstraintTy VarPos (SmallVector<int64_t , 8 >(Value2Index.size () + 1 , 0 ),
1623
- false , false , false );
1624
- VarPos.Coefficients [Value2Index[V]] = -1 ;
1625
- CSToUse.addVariableRow (VarPos.Coefficients );
1626
- DFSInStack.emplace_back (NumIn, NumOut, R.IsSigned ,
1627
- SmallVector<Value *, 2 >());
1628
- }
1629
- }
1611
+ LLVM_DEBUG ({
1612
+ dbgs () << " constraint: " ;
1613
+ dumpConstraint (R.Coefficients , getValue2Index (R.IsSigned ));
1614
+ dbgs () << " \n " ;
1615
+ });
1630
1616
1631
- if (R.isEq ()) {
1632
- // Also add the inverted constraint for equality constraints.
1633
- for (auto &Coeff : R.Coefficients )
1634
- Coeff *= -1 ;
1635
- CSToUse.addVariableRowFill (R.Coefficients );
1617
+ DFSInStack.emplace_back (NumIn, NumOut, R.IsSigned ,
1618
+ std::move (ValuesToRelease));
1636
1619
1620
+ if (!R.IsSigned ) {
1621
+ for (Value *V : NewVariables) {
1622
+ ConstraintTy VarPos (SmallVector<int64_t , 8 >(Value2Index.size () + 1 , 0 ),
1623
+ false , false , false );
1624
+ VarPos.Coefficients [Value2Index[V]] = -1 ;
1625
+ CSToUse.addVariableRow (VarPos.Coefficients );
1637
1626
DFSInStack.emplace_back (NumIn, NumOut, R.IsSigned ,
1638
1627
SmallVector<Value *, 2 >());
1639
1628
}
1640
1629
}
1630
+
1631
+ if (R.isEq ()) {
1632
+ // Also add the inverted constraint for equality constraints.
1633
+ for (auto &Coeff : R.Coefficients )
1634
+ Coeff *= -1 ;
1635
+ CSToUse.addVariableRowFill (R.Coefficients );
1636
+
1637
+ DFSInStack.emplace_back (NumIn, NumOut, R.IsSigned ,
1638
+ SmallVector<Value *, 2 >());
1639
+ }
1641
1640
}
1642
1641
1643
1642
static bool replaceSubOverflowUses (IntrinsicInst *II, Value *A, Value *B,
0 commit comments