[llvm] [ValueTracking] Handle range attributes (PR #85143)

Andreas Jonson via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 17 15:27:07 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:

fixed now

https://github.com/llvm/llvm-project/pull/85143


More information about the llvm-commits mailing list