[llvm] [ValueTracking] Add support for overflow detection functions is `isKnownNonZero` (PR #87701)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 06:08:32 PDT 2024


================
@@ -2786,6 +2791,35 @@ static bool isKnownNonZeroFromOperator(const Operator *I,
     // handled in isKnownNonZero.
     return false;
   }
+  case Instruction::ExtractValue:
+    if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I->getOperand(0))) {
+      const ExtractValueInst *EVI = cast<ExtractValueInst>(I);
+      if (EVI->getNumIndices() != 1 || EVI->getIndices()[0] != 0)
+        break;
+      switch (II->getIntrinsicID()) {
+      default:
+        break;
+      case Intrinsic::uadd_with_overflow:
+      case Intrinsic::sadd_with_overflow:
+        return isNonZeroAdd(APInt::getAllOnes(DemandedElts.getBitWidth()),
----------------
dtcxzyw wrote:

Why not pass `DemandedElts` directly? Can you add more comments here?


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


More information about the llvm-commits mailing list