[clang] [clang] Implement constexpr bit_cast for vectors (PR #66894)
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 4 11:35:48 PDT 2023
================
@@ -7441,6 +7500,28 @@ static bool handleLValueToRValueBitCast(EvalInfo &Info, APValue &DestValue,
return true;
}
+static bool handleLValueToRValueBitCast(EvalInfo &Info, APValue &DestValue,
+ APValue &SourceValue,
+ const CastExpr *BCE) {
+ assert(CHAR_BIT == 8 && Info.Ctx.getTargetInfo().getCharWidth() == 8 &&
+ "no host or target supports non 8-bit chars");
+ assert(SourceValue.isLValue() &&
+ "LValueToRValueBitcast requires an lvalue operand!");
+
+ if (!checkBitCastConstexprEligibility(&Info, Info.Ctx, BCE))
+ return false;
----------------
zygoloid wrote:
Can we avoid doing this twice (once here and again in `handleRValueToRValueBitCast`? It does a recursive walk of the source and destination types so isn't all that cheap.
https://github.com/llvm/llvm-project/pull/66894
More information about the cfe-commits
mailing list