[llvm] [X86] Implement CRC32 const folding (PR #219452)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 03:17:01 PDT 2026


================
@@ -2260,6 +2260,29 @@ X86TTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
     }
     break;
 
+  case Intrinsic::x86_sse42_crc32_32_8:
+  case Intrinsic::x86_sse42_crc32_32_16:
+  case Intrinsic::x86_sse42_crc32_32_32:
+  case Intrinsic::x86_sse42_crc32_64_64: {
+    auto *CrcArg = dyn_cast<ConstantInt>(II.getArgOperand(0));
+    auto *DataArg = dyn_cast<ConstantInt>(II.getArgOperand(1));
+    if (!CrcArg || !DataArg)
+      break;
+
+    // If both operands are constant, we can completely constant fold this.
+    uint64_t Crc = CrcArg->getZExtValue() & 0xffffffff;
+    uint64_t Data = DataArg->getZExtValue();
----------------
RKSimon wrote:

shouldn't these be uint32_t?

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


More information about the llvm-commits mailing list