Skip to content

Commit 3250305

Browse files
committed
[LoopUnrollAnalyzer] Use computeConstantDifference()
This is faster than checking for a SCEVConstant getMinusSCEV() result. The results should be the same for non-degenerate cases.
1 parent 721fdf1 commit 3250305

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Analysis/LoopUnrollAnalyzer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ bool UnrolledInstAnalyzer::simplifyInstWithSCEV(Instruction *I) {
5858
auto *Base = dyn_cast<SCEVUnknown>(SE.getPointerBase(S));
5959
if (!Base)
6060
return false;
61-
auto *Offset =
62-
dyn_cast<SCEVConstant>(SE.getMinusSCEV(ValueAtIteration, Base));
61+
std::optional<APInt> Offset =
62+
SE.computeConstantDifference(ValueAtIteration, Base);
6363
if (!Offset)
6464
return false;
6565
SimplifiedAddress Address;
6666
Address.Base = Base->getValue();
67-
Address.Offset = Offset->getAPInt();
67+
Address.Offset = *Offset;
6868
SimplifiedAddresses[I] = Address;
6969
return false;
7070
}

0 commit comments

Comments
 (0)