[clang] [clang] Implement constexpr bit_cast for vectors (PR #66894)
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 20 13:20:29 PDT 2023
================
@@ -7095,6 +7096,21 @@ class APValueToBufferConverter {
return true;
}
+ bool visitVector(const APValue &Val, QualType Ty, CharUnits Offset) {
+ const auto *VT = Ty->castAs<VectorType>();
+
+ CharUnits ElemWidth = Info.Ctx.getTypeSizeInChars(VT->getElementType());
+ unsigned VectorLength = Val.getVectorLength();
+ // Visit each of the vector elements
+ for (unsigned I = 0; I != VectorLength; ++I) {
+ const APValue &SubObj = Val.getVectorElt(I);
+ if (!visit(SubObj, VT->getElementType(), Offset + I * ElemWidth))
----------------
zygoloid wrote:
This isn't correct for a vector with element type `bool`, which Clang bit-packs.
https://github.com/llvm/llvm-project/pull/66894
More information about the cfe-commits
mailing list