[llvm-branch-commits] [llvm] [InstSimplify] Simplify `bitinsert` and `bitextract` (PR #229125)

Yingwei Zheng via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Oct 6 11:53:02 PDT 2026


================
@@ -5616,6 +5616,89 @@ Value *llvm::simplifyExtractElementInst(Value *Vec, Value *Idx,
   return ::simplifyExtractElementInst(Vec, Idx, Q, RecursionLimit);
 }
 
+/// Return true if accessing the bit range of type Ty at Offset in a value of
+/// type SrcTy is poison.
+static bool isPoisonBitRange(Value *Offset, Type *Ty, Type *SrcTy,
+                             const SimplifyQuery &Q) {
+  // A poison offset makes the result poison. An undef offset can be chosen to
+  // be out of range, which also makes the result poison.
+  if (isa<PoisonValue>(Offset) || Q.isUndefValue(Offset))
+    return true;
+
+  // Accessing bits past the end of the value is poison.
+  const APInt *Off;
+  return match(Offset, m_APInt(Off)) &&
----------------
dtcxzyw wrote:

Use `m_ConstantInt`.


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


More information about the llvm-branch-commits mailing list