[llvm] [ValueTracking] Handle intrinsics in `computeConstantRange` (PR #100870)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 27 06:44:27 PDT 2024
================
@@ -9728,6 +9728,17 @@ ConstantRange llvm::computeConstantRange(const Value *V, bool ForSigned,
if (const auto *CB = dyn_cast<CallBase>(V))
if (std::optional<ConstantRange> Range = CB->getRange())
CR = CR.intersectWith(*Range);
+
+ if (const auto *II = dyn_cast<IntrinsicInst>(V)) {
+ Intrinsic::ID IID = II->getIntrinsicID();
+ if (ConstantRange::isIntrinsicSupported(IID)) {
+ SmallVector<ConstantRange, 2> OpRanges;
+ for (Value *Op : II->args())
+ OpRanges.push_back(computeConstantRange(Op, ForSigned, UseInstrInfo,
+ AC, CtxI, DT, Depth + 1));
+ CR = CR.intersectWith(ConstantRange::intrinsic(IID, OpRanges));
+ }
+ }
----------------
nikic wrote:
Placing the code here makes no sense, there is already getRangeForIntrinsic above.
https://github.com/llvm/llvm-project/pull/100870
More information about the llvm-commits
mailing list