@@ -7352,31 +7352,6 @@ class APValueToBufferConverter {
7352
7352
const VectorType *VTy = Ty->castAs<VectorType>();
7353
7353
QualType EltTy = VTy->getElementType();
7354
7354
unsigned NElts = VTy->getNumElements();
7355
- unsigned EltSize =
7356
- VTy->isExtVectorBoolType() ? 1 : Info.Ctx.getTypeSize(EltTy);
7357
-
7358
- if ((NElts * EltSize) % Info.Ctx.getCharWidth() != 0) {
7359
- // The vector's size in bits is not a multiple of the target's byte size,
7360
- // so its layout is unspecified. For now, we'll simply treat these cases
7361
- // as unsupported (this should only be possible with OpenCL bool vectors
7362
- // whose element count isn't a multiple of the byte size).
7363
- Info.FFDiag(BCE->getBeginLoc(),
7364
- diag::note_constexpr_bit_cast_invalid_vector)
7365
- << Ty.getCanonicalType() << EltSize << NElts
7366
- << Info.Ctx.getCharWidth();
7367
- return false;
7368
- }
7369
-
7370
- if (EltTy->isRealFloatingType() && &Info.Ctx.getFloatTypeSemantics(EltTy) ==
7371
- &APFloat::x87DoubleExtended()) {
7372
- // The layout for x86_fp80 vectors seems to be handled very inconsistently
7373
- // by both clang and LLVM, so for now we won't allow bit_casts involving
7374
- // it in a constexpr context.
7375
- Info.FFDiag(BCE->getBeginLoc(),
7376
- diag::note_constexpr_bit_cast_unsupported_type)
7377
- << EltTy;
7378
- return false;
7379
- }
7380
7355
7381
7356
if (VTy->isExtVectorBoolType()) {
7382
7357
// Special handling for OpenCL bool vectors:
@@ -7643,28 +7618,6 @@ class BufferToAPValueConverter {
7643
7618
unsigned EltSize =
7644
7619
VTy->isExtVectorBoolType() ? 1 : Info.Ctx.getTypeSize(EltTy);
7645
7620
7646
- if ((NElts * EltSize) % Info.Ctx.getCharWidth() != 0) {
7647
- // The vector's size in bits is not a multiple of the target's byte size,
7648
- // so its layout is unspecified. For now, we'll simply treat these cases
7649
- // as unsupported (this should only be possible with OpenCL bool vectors
7650
- // whose element count isn't a multiple of the byte size).
7651
- Info.FFDiag(BCE->getBeginLoc(),
7652
- diag::note_constexpr_bit_cast_invalid_vector)
7653
- << QualType(VTy, 0) << EltSize << NElts << Info.Ctx.getCharWidth();
7654
- return std::nullopt;
7655
- }
7656
-
7657
- if (EltTy->isRealFloatingType() && &Info.Ctx.getFloatTypeSemantics(EltTy) ==
7658
- &APFloat::x87DoubleExtended()) {
7659
- // The layout for x86_fp80 vectors seems to be handled very inconsistently
7660
- // by both clang and LLVM, so for now we won't allow bit_casts involving
7661
- // it in a constexpr context.
7662
- Info.FFDiag(BCE->getBeginLoc(),
7663
- diag::note_constexpr_bit_cast_unsupported_type)
7664
- << EltTy;
7665
- return std::nullopt;
7666
- }
7667
-
7668
7621
SmallVector<APValue, 4> Elts;
7669
7622
Elts.reserve(NElts);
7670
7623
if (VTy->isExtVectorBoolType()) {
@@ -7793,6 +7746,32 @@ static bool checkBitCastConstexprEligibilityType(SourceLocation Loc,
7793
7746
Info, Ctx, CheckingDest))
7794
7747
return false;
7795
7748
7749
+ if (const auto *VTy = Ty->getAs<VectorType>()) {
7750
+ QualType EltTy = VTy->getElementType();
7751
+ unsigned NElts = VTy->getNumElements();
7752
+ unsigned EltSize = VTy->isExtVectorBoolType() ? 1 : Ctx.getTypeSize(EltTy);
7753
+
7754
+ if ((NElts * EltSize) % Ctx.getCharWidth() != 0) {
7755
+ // The vector's size in bits is not a multiple of the target's byte size,
7756
+ // so its layout is unspecified. For now, we'll simply treat these cases
7757
+ // as unsupported (this should only be possible with OpenCL bool vectors
7758
+ // whose element count isn't a multiple of the byte size).
7759
+ Info->FFDiag(Loc, diag::note_constexpr_bit_cast_invalid_vector)
7760
+ << QualType(VTy, 0) << EltSize << NElts << Ctx.getCharWidth();
7761
+ return false;
7762
+ }
7763
+
7764
+ if (EltTy->isRealFloatingType() &&
7765
+ &Ctx.getFloatTypeSemantics(EltTy) == &APFloat::x87DoubleExtended()) {
7766
+ // The layout for x86_fp80 vectors seems to be handled very inconsistently
7767
+ // by both clang and LLVM, so for now we won't allow bit_casts involving
7768
+ // it in a constexpr context.
7769
+ Info->FFDiag(Loc, diag::note_constexpr_bit_cast_unsupported_type)
7770
+ << EltTy;
7771
+ return false;
7772
+ }
7773
+ }
7774
+
7796
7775
return true;
7797
7776
}
7798
7777
0 commit comments