@@ -88,13 +88,12 @@ static Instruction *getContextInstForUse(Use &U) {
88
88
namespace {
89
89
// / Struct to express a condition of the form %Op0 Pred %Op1.
90
90
struct ConditionTy {
91
- CmpInst::Predicate Pred;
92
- Value *Op0;
93
- Value *Op1;
91
+ CmpPredicate Pred;
92
+ Value *Op0 = nullptr ;
93
+ Value *Op1 = nullptr ;
94
94
95
- ConditionTy ()
96
- : Pred(CmpInst::BAD_ICMP_PREDICATE), Op0(nullptr ), Op1(nullptr ) {}
97
- ConditionTy (CmpInst::Predicate Pred, Value *Op0, Value *Op1)
95
+ ConditionTy () = default ;
96
+ ConditionTy (CmpPredicate Pred, Value *Op0, Value *Op1)
98
97
: Pred(Pred), Op0(Op0), Op1(Op1) {}
99
98
};
100
99
@@ -132,18 +131,17 @@ struct FactOrCheck {
132
131
Ty(Ty) {}
133
132
134
133
FactOrCheck (DomTreeNode *DTN, Use *U)
135
- : U(U), DoesHold(CmpInst::BAD_ICMP_PREDICATE, nullptr , nullptr ),
136
- NumIn(DTN->getDFSNumIn ()), NumOut(DTN->getDFSNumOut ()),
134
+ : U(U), NumIn(DTN->getDFSNumIn ()), NumOut(DTN->getDFSNumOut ()),
137
135
Ty(EntryTy::UseCheck) {}
138
136
139
- FactOrCheck (DomTreeNode *DTN, CmpInst::Predicate Pred, Value *Op0, Value *Op1,
140
- ConditionTy Precond = ConditionTy() )
137
+ FactOrCheck (DomTreeNode *DTN, CmpPredicate Pred, Value *Op0, Value *Op1,
138
+ ConditionTy Precond = {} )
141
139
: Cond(Pred, Op0, Op1), DoesHold(Precond), NumIn(DTN->getDFSNumIn ()),
142
140
NumOut(DTN->getDFSNumOut ()), Ty(EntryTy::ConditionFact) {}
143
141
144
- static FactOrCheck getConditionFact (DomTreeNode *DTN, CmpInst::Predicate Pred,
142
+ static FactOrCheck getConditionFact (DomTreeNode *DTN, CmpPredicate Pred,
145
143
Value *Op0, Value *Op1,
146
- ConditionTy Precond = ConditionTy() ) {
144
+ ConditionTy Precond = {} ) {
147
145
return FactOrCheck (DTN, Pred, Op0, Op1, Precond);
148
146
}
149
147
@@ -1176,8 +1174,7 @@ void State::addInfoFor(BasicBlock &BB) {
1176
1174
if (auto *Cmp = dyn_cast<ICmpInst>(Cur)) {
1177
1175
WorkList.emplace_back (FactOrCheck::getConditionFact (
1178
1176
DT.getNode (Successor),
1179
- IsOr ? CmpInst::getInversePredicate (Cmp->getPredicate ())
1180
- : Cmp->getPredicate (),
1177
+ IsOr ? Cmp->getInverseCmpPredicate () : Cmp->getCmpPredicate (),
1181
1178
Cmp->getOperand (0 ), Cmp->getOperand (1 )));
1182
1179
continue ;
1183
1180
}
@@ -1201,13 +1198,12 @@ void State::addInfoFor(BasicBlock &BB) {
1201
1198
return ;
1202
1199
if (canAddSuccessor (BB, Br->getSuccessor (0 )))
1203
1200
WorkList.emplace_back (FactOrCheck::getConditionFact (
1204
- DT.getNode (Br->getSuccessor (0 )), CmpI->getPredicate (),
1201
+ DT.getNode (Br->getSuccessor (0 )), CmpI->getCmpPredicate (),
1205
1202
CmpI->getOperand (0 ), CmpI->getOperand (1 )));
1206
1203
if (canAddSuccessor (BB, Br->getSuccessor (1 )))
1207
1204
WorkList.emplace_back (FactOrCheck::getConditionFact (
1208
- DT.getNode (Br->getSuccessor (1 )),
1209
- CmpInst::getInversePredicate (CmpI->getPredicate ()), CmpI->getOperand (0 ),
1210
- CmpI->getOperand (1 )));
1205
+ DT.getNode (Br->getSuccessor (1 )), CmpI->getInverseCmpPredicate (),
1206
+ CmpI->getOperand (0 ), CmpI->getOperand (1 )));
1211
1207
}
1212
1208
1213
1209
#ifndef NDEBUG
@@ -1806,7 +1802,7 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
1806
1802
continue ;
1807
1803
}
1808
1804
1809
- auto AddFact = [&](CmpInst::Predicate Pred, Value *A, Value *B) {
1805
+ auto AddFact = [&](CmpPredicate Pred, Value *A, Value *B) {
1810
1806
LLVM_DEBUG (dbgs () << " Processing fact to add to the system: " ;
1811
1807
dumpUnpackedICmp (dbgs (), Pred, A, B); dbgs () << " \n " );
1812
1808
if (Info.getCS (CmpInst::isSigned (Pred)).size () > MaxRows) {
@@ -1820,7 +1816,18 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
1820
1816
if (ReproducerModule && DFSInStack.size () > ReproducerCondStack.size ())
1821
1817
ReproducerCondStack.emplace_back (Pred, A, B);
1822
1818
1823
- Info.transferToOtherSystem (Pred, A, B, CB.NumIn , CB.NumOut , DFSInStack);
1819
+ if (ICmpInst::isRelational (Pred)) {
1820
+ // If samesign is present on the ICmp, simply flip the sign of the
1821
+ // predicate, transferring the information from the signed system to the
1822
+ // unsigned system, and viceversa.
1823
+ if (Pred.hasSameSign ())
1824
+ Info.addFact (ICmpInst::getFlippedSignednessPredicate (Pred), A, B,
1825
+ CB.NumIn , CB.NumOut , DFSInStack);
1826
+ else
1827
+ Info.transferToOtherSystem (Pred, A, B, CB.NumIn , CB.NumOut ,
1828
+ DFSInStack);
1829
+ }
1830
+
1824
1831
if (ReproducerModule && DFSInStack.size () > ReproducerCondStack.size ()) {
1825
1832
// Add dummy entries to ReproducerCondStack to keep it in sync with
1826
1833
// DFSInStack.
0 commit comments