[llvm] [ValueTracking] Try to infer range of select from true and false values. (PR #68256)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 4 18:50:17 PDT 2023
================
@@ -8854,11 +8854,16 @@ ConstantRange llvm::computeConstantRange(const Value *V, bool ForSigned,
} else if (auto *II = dyn_cast<IntrinsicInst>(V))
CR = getRangeForIntrinsic(*II);
else if (auto *SI = dyn_cast<SelectInst>(V)) {
+ ConstantRange CRTrue = computeConstantRange(
+ SI->getTrueValue(), ForSigned, UseInstrInfo, AC, CtxI, DT, Depth + 1);
+ ConstantRange CRFalse = computeConstantRange(
+ SI->getFalseValue(), ForSigned, UseInstrInfo, AC, CtxI, DT, Depth + 1);
+ CR = CRTrue.unionWith(CRFalse);
----------------
goldsteinn wrote:
Still think the logic belongs here actually, but feel free to commit w.o adding, I'll likely add a follow up shortly after.
https://github.com/llvm/llvm-project/pull/68256
More information about the llvm-commits
mailing list