[clang] [X86][Clang] allow CRC32 intrinsics to be used in constexp (PR #173908)

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 14 07:27:08 PST 2026


================
@@ -717,6 +717,52 @@ static bool interp__builtin_popcount(InterpState &S, CodePtr OpPC,
   return true;
 }
 
+static bool interp__builtin_ia32_crc32(InterpState &S, CodePtr OpPC,
+                                       const InterpFrame *Frame,
+                                       const CallExpr *Call,
+                                       unsigned BuiltinID) {
+  APSInt Data = popToAPSInt(S, Call->getArg(1));
+  APSInt CRC = popToAPSInt(S, Call->getArg(0));
+
+  uint64_t CRCVal = CRC.getZExtValue();
+  uint64_t DataVal = Data.getZExtValue();
+
+  // Determine the data width based on the builtin
+  unsigned DataBytes;
+  switch (BuiltinID) {
----------------
RKSimon wrote:

We can avoid this switch statement by passing in unsigned DataBytes as an additional argument to interp__builtin_ia32_crc32

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


More information about the cfe-commits mailing list