[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:22:00 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:
not quite, but the logic i'm proposing looks like it belongs better there. I'll make a patch for that.
https://github.com/llvm/llvm-project/pull/68256
More information about the llvm-commits
mailing list