[llvm] 42aaab3 - [NFC][SCEV] `GetMinTrailingZerosImpl()`: deduplicate handling
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 22 12:28:18 PST 2023
Author: Roman Lebedev
Date: 2023-01-22T23:28:01+03:00
New Revision: 42aaab3b4545534e41da56961f9b62aa8af771c9
URL: https://github.com/llvm/llvm-project/commit/42aaab3b4545534e41da56961f9b62aa8af771c9
DIFF: https://github.com/llvm/llvm-project/commit/42aaab3b4545534e41da56961f9b62aa8af771c9.diff
LOG: [NFC][SCEV] `GetMinTrailingZerosImpl()`: deduplicate handling
`scPtrToInt` recieves same treatment as normal n-ary ops.
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index c7066a3c275e..62097db4f0cc 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -6336,8 +6336,6 @@ uint32_t ScalarEvolution::GetMinTrailingZerosImpl(const SCEV *S) {
? getTypeSizeInBits(E->getType())
: OpRes;
}
- case scPtrToInt:
- return GetMinTrailingZeros(cast<SCEVPtrToIntExpr>(S)->getOperand());
case scMulExpr: {
const SCEVMulExpr *M = cast<SCEVMulExpr>(S);
// The result is the sum of all operands results.
@@ -6351,6 +6349,7 @@ uint32_t ScalarEvolution::GetMinTrailingZerosImpl(const SCEV *S) {
}
case scUDivExpr:
return 0;
+ case scPtrToInt:
case scAddExpr:
case scAddRecExpr:
case scUMaxExpr:
@@ -6359,10 +6358,10 @@ uint32_t ScalarEvolution::GetMinTrailingZerosImpl(const SCEV *S) {
case scSMinExpr:
case scSequentialUMinExpr: {
// The result is the min of all operands results.
- const SCEVNAryExpr *M = cast<SCEVNAryExpr>(S);
- uint32_t MinOpRes = GetMinTrailingZeros(M->getOperand(0));
- for (unsigned I = 1, E = M->getNumOperands(); MinOpRes && I != E; ++I)
- MinOpRes = std::min(MinOpRes, GetMinTrailingZeros(M->getOperand(I)));
+ ArrayRef<const SCEV *> Ops = S->operands();
+ uint32_t MinOpRes = GetMinTrailingZeros(Ops[0]);
+ for (unsigned I = 1, E = Ops.size(); MinOpRes && I != E; ++I)
+ MinOpRes = std::min(MinOpRes, GetMinTrailingZeros(Ops[I]));
return MinOpRes;
}
case scUnknown: {
More information about the llvm-commits
mailing list