Skip to content

Commit 3320c0d

Browse files
committed
[TSAR, Memory] Use optimizations for compareSCEVs.
1 parent d11fbf0 commit 3320c0d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/Support/SCEVUtils.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ Optional<int64_t> compareSCEVs(const SCEV *LHS, const SCEV *RHS,
718718
ScalarEvolution *SE) {
719719
assert(SE && "ScalarEvolution must be specified!");
720720
assert(LHS && RHS && "SCEV must be specified!");
721+
if (LHS == RHS)
722+
return 0;
721723
TypeQueue TQLHS, TQRHS;
722724
auto InnerLHS = getTypeQueue(TQLHS, LHS);
723725
auto InnerRHS = getTypeQueue(TQRHS, RHS);
@@ -766,9 +768,11 @@ Optional<int64_t> compareSCEVs(const SCEV *LHS, const SCEV *RHS,
766768
}
767769
return None;
768770
}
769-
if (auto Const = llvm::dyn_cast<llvm::SCEVConstant>(
770-
SE->getMinusSCEV(InnerLHS, InnerRHS)))
771-
return Const->getAPInt().getSExtValue();
771+
if (InnerLHS == InnerRHS)
772+
return 0;
773+
auto Const = SE->computeConstantDifference(InnerLHS, InnerRHS);
774+
if (Const)
775+
return Const->getSExtValue();
772776
return None;
773777
}
774778
}

0 commit comments

Comments
 (0)