[clang] [clang] Support constexpr bitcasts between equal-size vector and integer types (PR #167016)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 10 03:07:05 PST 2025


================
@@ -17724,7 +17078,24 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
   case CK_HLSLAggregateSplatCast:
     llvm_unreachable("invalid cast kind for integral value");
 
-  case CK_BitCast:
+  case CK_BitCast:{
+  APValue Sub;
+  if (!Evaluate(Sub, Info, E->getSubExpr()))
+    return false;
+
+  QualType SrcTy = E->getSubExpr()->getType();
+  QualType DstTy = E->getType();
+
+  // Allow reinterpretation if bit widths match
+  if (Info.Ctx.getTypeSize(SrcTy) == Info.Ctx.getTypeSize(DstTy)) {
+    // Use APValue::BitCast if available, else just copy value bits
----------------
tbaederr wrote:

What is `APValue::BitCast`?

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


More information about the cfe-commits mailing list