Skip to content

Commit 28941e8

Browse files
committed
[SCCP] Avoid computing range if the instructions are already refined.
1 parent ec93ce5 commit 28941e8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/lib/Transforms/Utils/SCCPSolver.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ static bool refineInstruction(SCCPSolver &Solver,
120120
};
121121

122122
if (isa<OverflowingBinaryOperator>(Inst)) {
123+
if (Inst.hasNoSignedWrap() && Inst.hasNoUnsignedWrap())
124+
return false;
125+
123126
auto RangeA = GetRange(Inst.getOperand(0));
124127
auto RangeB = GetRange(Inst.getOperand(1));
125128
if (!Inst.hasNoUnsignedWrap()) {
@@ -147,6 +150,9 @@ static bool refineInstruction(SCCPSolver &Solver,
147150
Changed = true;
148151
}
149152
} else if (TruncInst *TI = dyn_cast<TruncInst>(&Inst)) {
153+
if (TI->hasNoSignedWrap() && TI->hasNoUnsignedWrap())
154+
return false;
155+
150156
auto Range = GetRange(Inst.getOperand(0));
151157
uint64_t DestWidth = TI->getDestTy()->getScalarSizeInBits();
152158
if (!TI->hasNoUnsignedWrap()) {

0 commit comments

Comments
 (0)