[PATCH] D150541: [SCEV][NFC-mostly] Remove constant handling in TripMultiple computation
Joshua Cao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 16 20:56:47 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb27f14d920e1: [SCEV][NFC-mostly] Remove constant handling in TripMultiple computation (authored by caojoshua).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150541/new/
https://reviews.llvm.org/D150541
Files:
llvm/lib/Analysis/ScalarEvolution.cpp
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -8335,29 +8335,12 @@
// Get the trip count
const SCEV *TCExpr = getTripCountFromExitCount(applyLoopGuards(ExitCount, L));
+ APInt Multiple = getNonZeroConstantMultiple(TCExpr);
// If a trip multiple is huge (>=2^32), the trip count is still divisible by
// the greatest power of 2 divisor less than 2^32.
- auto GetSmallMultiple = [](unsigned TrailingZeros) {
- return 1U << std::min((uint32_t)31, TrailingZeros);
- };
-
- const SCEVConstant *TC = dyn_cast<SCEVConstant>(TCExpr);
- if (!TC) {
- APInt Multiple = getNonZeroConstantMultiple(TCExpr);
- return Multiple.getActiveBits() > 32
- ? 1
- : Multiple.zextOrTrunc(32).getZExtValue();
- }
-
- ConstantInt *Result = TC->getValue();
- assert(Result && "SCEVConstant expected to have non-null ConstantInt");
- assert(Result->getValue() != 0 && "trip count should never be zero");
-
- // Guard against huge trip multiples.
- if (Result->getValue().getActiveBits() > 32)
- return GetSmallMultiple(Result->getValue().countTrailingZeros());
-
- return (unsigned)Result->getZExtValue();
+ return Multiple.getActiveBits() > 32
+ ? 1U << std::min((uint32_t)31, Multiple.countTrailingZeros())
+ : Multiple.zextOrTrunc(32).getZExtValue();
}
/// Returns the largest constant divisor of the trip count of this loop as a
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150541.522890.patch
Type: text/x-patch
Size: 1554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230517/32046092/attachment-0001.bin>
More information about the llvm-commits
mailing list