[llvm] [ValueTracking] Handle range attributes (PR #85143)
Andreas Jonson via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 17 12:00:05 PDT 2024
================
@@ -1467,14 +1467,20 @@ static void computeKnownBitsFromOperator(const Operator *I,
break;
}
case Instruction::Call:
- case Instruction::Invoke:
+ case Instruction::Invoke: {
// If range metadata is attached to this call, set known bits from that,
// and then intersect with known bits based on other properties of the
// function.
if (MDNode *MD =
Q.IIQ.getMetadata(cast<Instruction>(I), LLVMContext::MD_range))
computeKnownBitsFromRangeMetadata(*MD, Known);
- if (const Value *RV = cast<CallBase>(I)->getReturnedArgOperand()) {
+
+ const CallBase *CB = cast<CallBase>(I);
+
+ if (std::optional<ConstantRange> Range = CB->getRange())
+ Known = Range->toKnownBits();
----------------
andjo403 wrote:
hmm maybe it was suggested to forbid range metadata on calls in the future https://github.com/llvm/llvm-project/pull/84627#discussion_r1518589822 but maybe needed until then or at least swap the order so this is done before the range metadata handling
https://github.com/llvm/llvm-project/pull/85143
More information about the llvm-commits
mailing list