[llvm] first draft (PR #199558)

Arihant Chawla via llvm-commits llvm-commits at lists.llvm.org
Mon May 25 10:27:18 PDT 2026


https://github.com/ArihantChawla created https://github.com/llvm/llvm-project/pull/199558

None

>From 5ba01fe8c255d977b52a783b149429fd66bbc30d Mon Sep 17 00:00:00 2001
From: arihant <arihant.chawla at yahoo.com>
Date: Mon, 25 May 2026 22:55:34 +0530
Subject: [PATCH] first draft

---
 llvm/lib/Analysis/ValueTracking.cpp | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 3be0db5ad9c7e..33cb3750a45d8 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2232,6 +2232,29 @@ static void computeKnownBitsFromOperator(const Operator *I,
             I, DemandedElts, Q, Depth, KnownBits::ssub_sat);
         break;
       }
+      case Intrinsic::x86_bmi_bextr_32:
+      case Intrinsic::x86_bmi_bextr_64:
+      case Intrinsic::x86_tbm_bextri_u32:
+      case Intrinsic::x86_tbm_bextri_u64: {
+        Value *Val = I->getOperand(1);
+        unsigned Length = 0, Shift;
+        if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) {
+          if (CI->getBitWidth() <= BitWidth) {
+            Shift = CI->getValue().extractBitsAsZExtValue(8, 0);
+            Length = CI->getValue().extractBitsAsZExtValue(8, 8);
+          }
+        }
+        if (Length == 0) {
+          Known.setAllZero();
+          break;
+        }
+        if ((Shift + Length) <= BitWidth) {
+          computeKnownBits(I->getOperand(0), DemandedElts, Known, Q, Depth + 1);
+          Known = Known.extractBits(Length, Shift);
+          Known = Known.zextOrTrunc(BitWidth);
+        }
+        break;
+      }
       case Intrinsic::riscv_vsetvli:
       case Intrinsic::riscv_vsetvlimax: {
         bool HasAVL = II->getIntrinsicID() == Intrinsic::riscv_vsetvli;



More information about the llvm-commits mailing list