[llvm] Fix InstCombine variable folding crash (PR #205148)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 5 12:10:29 PDT 2026


================
@@ -1760,10 +1760,13 @@ InstCombinerImpl::foldVariableSignZeroExtensionOfVariableHighBitExtract(
 
   // Check that constant C is a splat of the element-wise bitwidth of V.
   auto BitWidthSplat = [](Constant *C, Value *V) {
-    return match(
-        C, m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ,
-                              APInt(C->getType()->getScalarSizeInBits(),
-                                    V->getType()->getScalarSizeInBits())));
+    auto CBitWidth = C->getType()->getScalarSizeInBits();
+    auto VBitWidth = V->getType()->getScalarSizeInBits();
+    if (!llvm::isUIntN(CBitWidth, VBitWidth))
+      return false;
+
+    return match(C, m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ,
----------------
rdevshp wrote:

I have switched to using `m_SpecificIntAllowPoison(uint64_t V)`.

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


More information about the llvm-commits mailing list