[llvm] 3230037 - [NFCI] `ScalarEvolution::getRangeRef()`: collapse `SCEVMinMaxExpr` handling
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 7 13:24:01 PST 2022
Author: Roman Lebedev
Date: 2022-01-08T00:23:08+03:00
New Revision: 32300375f5508c1d523400be71e0799fcdfa074a
URL: https://github.com/llvm/llvm-project/commit/32300375f5508c1d523400be71e0799fcdfa074a
DIFF: https://github.com/llvm/llvm-project/commit/32300375f5508c1d523400be71e0799fcdfa074a.diff
LOG: [NFCI] `ScalarEvolution::getRangeRef()`: collapse `SCEVMinMaxExpr` handling
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 513b2c0e5da1d..2b1f84017152e 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -6060,35 +6060,30 @@ ScalarEvolution::getRangeRef(const SCEV *S,
ConservativeResult.intersectWith(X, RangeType));
}
- if (const SCEVSMaxExpr *SMax = dyn_cast<SCEVSMaxExpr>(S)) {
- ConstantRange X = getRangeRef(SMax->getOperand(0), SignHint);
- for (unsigned i = 1, e = SMax->getNumOperands(); i != e; ++i)
- X = X.smax(getRangeRef(SMax->getOperand(i), SignHint));
- return setRange(SMax, SignHint,
- ConservativeResult.intersectWith(X, RangeType));
- }
-
- if (const SCEVUMaxExpr *UMax = dyn_cast<SCEVUMaxExpr>(S)) {
- ConstantRange X = getRangeRef(UMax->getOperand(0), SignHint);
- for (unsigned i = 1, e = UMax->getNumOperands(); i != e; ++i)
- X = X.umax(getRangeRef(UMax->getOperand(i), SignHint));
- return setRange(UMax, SignHint,
- ConservativeResult.intersectWith(X, RangeType));
- }
-
- if (const SCEVSMinExpr *SMin = dyn_cast<SCEVSMinExpr>(S)) {
- ConstantRange X = getRangeRef(SMin->getOperand(0), SignHint);
- for (unsigned i = 1, e = SMin->getNumOperands(); i != e; ++i)
- X = X.smin(getRangeRef(SMin->getOperand(i), SignHint));
- return setRange(SMin, SignHint,
- ConservativeResult.intersectWith(X, RangeType));
- }
+ if (isa<SCEVMinMaxExpr>(S)) {
+ Intrinsic::ID ID;
+ switch (S->getSCEVType()) {
+ case scUMaxExpr:
+ ID = Intrinsic::umax;
+ break;
+ case scSMaxExpr:
+ ID = Intrinsic::smax;
+ break;
+ case scUMinExpr:
+ ID = Intrinsic::umin;
+ break;
+ case scSMinExpr:
+ ID = Intrinsic::smin;
+ break;
+ default:
+ llvm_unreachable("Unknown SCEVMinMaxExpr.");
+ }
- if (const SCEVUMinExpr *UMin = dyn_cast<SCEVUMinExpr>(S)) {
- ConstantRange X = getRangeRef(UMin->getOperand(0), SignHint);
- for (unsigned i = 1, e = UMin->getNumOperands(); i != e; ++i)
- X = X.umin(getRangeRef(UMin->getOperand(i), SignHint));
- return setRange(UMin, SignHint,
+ const auto *NAry = cast<SCEVNAryExpr>(S);
+ ConstantRange X = getRangeRef(NAry->getOperand(0), SignHint);
+ for (unsigned i = 1, e = NAry->getNumOperands(); i != e; ++i)
+ X = X.intrinsic(ID, {X, getRangeRef(NAry->getOperand(i), SignHint)});
+ return setRange(S, SignHint,
ConservativeResult.intersectWith(X, RangeType));
}
More information about the llvm-commits
mailing list