Skip to content

Commit 0e24c32

Browse files
committed
[SCCP] Avoid some uses of SCCPSolver::isOverdefined (NFCI)
This is a confusingly named helper than means "is not unknown, undef or constant". Prefer the more obvious ValueLattice API instead. Most of these checks are for values which are forced to overdefined by undef resolution, in which case only actual overdefined values are relevant.
1 parent a195e2d commit 0e24c32

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

llvm/lib/Transforms/Utils/SCCPSolver.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ void SCCPInstVisitor::visitInsertValueInst(InsertValueInst &IVI) {
13641364

13651365
// resolvedUndefsIn might mark I as overdefined. Bail out, even if we would
13661366
// discover a concrete value later.
1367-
if (SCCPSolver::isOverdefined(ValueState[&IVI]))
1367+
if (ValueState[&IVI].isOverdefined())
13681368
return (void)markOverdefined(&IVI);
13691369

13701370
// If this has more than one index, we can't handle it, drive all results to
@@ -1436,7 +1436,7 @@ void SCCPInstVisitor::visitUnaryOperator(Instruction &I) {
14361436
ValueLatticeElement &IV = ValueState[&I];
14371437
// resolvedUndefsIn might mark I as overdefined. Bail out, even if we would
14381438
// discover a concrete value later.
1439-
if (SCCPSolver::isOverdefined(IV))
1439+
if (IV.isOverdefined())
14401440
return (void)markOverdefined(&I);
14411441

14421442
// If something is unknown/undef, wait for it to resolve.
@@ -1461,7 +1461,7 @@ void SCCPInstVisitor::visitFreezeInst(FreezeInst &I) {
14611461
ValueLatticeElement &IV = ValueState[&I];
14621462
// resolvedUndefsIn might mark I as overdefined. Bail out, even if we would
14631463
// discover a concrete value later.
1464-
if (SCCPSolver::isOverdefined(IV))
1464+
if (IV.isOverdefined())
14651465
return (void)markOverdefined(&I);
14661466

14671467
// If something is unknown/undef, wait for it to resolve.
@@ -1541,7 +1541,7 @@ void SCCPInstVisitor::visitBinaryOperator(Instruction &I) {
15411541
void SCCPInstVisitor::visitCmpInst(CmpInst &I) {
15421542
// Do not cache this lookup, getValueState calls later in the function might
15431543
// invalidate the reference.
1544-
if (SCCPSolver::isOverdefined(ValueState[&I]))
1544+
if (ValueState[&I].isOverdefined())
15451545
return (void)markOverdefined(&I);
15461546

15471547
Value *Op1 = I.getOperand(0);
@@ -1571,7 +1571,7 @@ void SCCPInstVisitor::visitCmpInst(CmpInst &I) {
15711571
// Handle getelementptr instructions. If all operands are constants then we
15721572
// can turn this into a getelementptr ConstantExpr.
15731573
void SCCPInstVisitor::visitGetElementPtrInst(GetElementPtrInst &I) {
1574-
if (SCCPSolver::isOverdefined(ValueState[&I]))
1574+
if (ValueState[&I].isOverdefined())
15751575
return (void)markOverdefined(&I);
15761576

15771577
SmallVector<Constant *, 8> Operands;
@@ -1582,9 +1582,6 @@ void SCCPInstVisitor::visitGetElementPtrInst(GetElementPtrInst &I) {
15821582
if (State.isUnknownOrUndef())
15831583
return; // Operands are not resolved yet.
15841584

1585-
if (SCCPSolver::isOverdefined(State))
1586-
return (void)markOverdefined(&I);
1587-
15881585
if (Constant *C = getConstant(State, I.getOperand(i)->getType())) {
15891586
Operands.push_back(C);
15901587
continue;

0 commit comments

Comments
 (0)