[llvm] b65f30d - [SCEV] Minor code motion to simplify a later patch [nfc]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 9 14:17:48 PDT 2021
Author: Philip Reames
Date: 2021-06-09T14:17:06-07:00
New Revision: b65f30d6fb6f5333dcb7c51f81c4309704c26f1f
URL: https://github.com/llvm/llvm-project/commit/b65f30d6fb6f5333dcb7c51f81c4309704c26f1f
DIFF: https://github.com/llvm/llvm-project/commit/b65f30d6fb6f5333dcb7c51f81c4309704c26f1f.diff
LOG: [SCEV] Minor code motion to simplify a later patch [nfc]
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 699be27f6f06..70191f1e2612 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -11423,8 +11423,9 @@ ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
if (!IV || IV->getLoop() != L || !IV->isAffine())
return getCouldNotCompute();
- bool NoWrap = ControlsExit &&
- IV->getNoWrapFlags(IsSigned ? SCEV::FlagNSW : SCEV::FlagNUW);
+ auto WrapType = IsSigned ? SCEV::FlagNSW : SCEV::FlagNUW;
+ bool NoWrap = ControlsExit && IV->getNoWrapFlags(WrapType);
+ ICmpInst::Predicate Cond = IsSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT;
const SCEV *Stride = IV->getStepRecurrence(*this);
@@ -11520,8 +11521,6 @@ ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
return getCouldNotCompute();
}
- ICmpInst::Predicate Cond = IsSigned ? ICmpInst::ICMP_SLT
- : ICmpInst::ICMP_ULT;
const SCEV *Start = IV->getStart();
const SCEV *End = RHS;
// When the RHS is not invariant, we do not know the end bound of the loop and
@@ -11604,8 +11603,9 @@ ScalarEvolution::howManyGreaterThans(const SCEV *LHS, const SCEV *RHS,
if (!IV || IV->getLoop() != L || !IV->isAffine())
return getCouldNotCompute();
- bool NoWrap = ControlsExit &&
- IV->getNoWrapFlags(IsSigned ? SCEV::FlagNSW : SCEV::FlagNUW);
+ auto WrapType = IsSigned ? SCEV::FlagNSW : SCEV::FlagNUW;
+ bool NoWrap = ControlsExit && IV->getNoWrapFlags(WrapType);
+ ICmpInst::Predicate Cond = IsSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
const SCEV *Stride = getNegativeSCEV(IV->getStepRecurrence(*this));
@@ -11621,9 +11621,6 @@ ScalarEvolution::howManyGreaterThans(const SCEV *LHS, const SCEV *RHS,
if (canIVOverflowOnGT(RHS, Stride, IsSigned))
return getCouldNotCompute();
- ICmpInst::Predicate Cond = IsSigned ? ICmpInst::ICMP_SGT
- : ICmpInst::ICMP_UGT;
-
const SCEV *Start = IV->getStart();
const SCEV *End = RHS;
if (!isLoopEntryGuardedByCond(L, Cond, getAddExpr(Start, Stride), RHS)) {
More information about the llvm-commits
mailing list