@@ -448,6 +448,10 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
448
448
449
449
QualType SubExprTy = SubExpr->getType ();
450
450
std::optional<PrimType> FromT = classify (SubExprTy);
451
+ // Casts from integer to vectors in C.
452
+ if (FromT && CE->getType ()->isVectorType ())
453
+ return this ->emitBuiltinBitCast (CE);
454
+
451
455
std::optional<PrimType> ToT = classify (CE->getType ());
452
456
if (!FromT || !ToT)
453
457
return false ;
@@ -6494,8 +6498,23 @@ bool Compiler<Emitter>::emitBuiltinBitCast(const CastExpr *E) {
6494
6498
}
6495
6499
6496
6500
// Get a pointer to the value-to-cast on the stack.
6497
- if (!this ->visit (SubExpr))
6498
- return false ;
6501
+ // For CK_LValueToRValueBitCast, this is always an lvalue and
6502
+ // we later assume it to be one (i.e. a PT_Ptr). However,
6503
+ // we call this function for other utility methods where
6504
+ // a bitcast might be useful, so convert it to a PT_Ptr in that case.
6505
+ if (SubExpr->isGLValue ()) {
6506
+ if (!this ->visit (SubExpr))
6507
+ return false ;
6508
+ } else if (std::optional<PrimType> FromT = classify (SubExpr)) {
6509
+ unsigned TempOffset = allocateLocalPrimitive (
6510
+ SubExpr, *FromT, /* IsConst=*/ true , /* IsExtended=*/ false );
6511
+ if (!this ->visit (SubExpr))
6512
+ return false ;
6513
+ if (!this ->emitSetLocal (*FromT, TempOffset, E))
6514
+ return false ;
6515
+ if (!this ->emitGetPtrLocal (TempOffset, E))
6516
+ return false ;
6517
+ }
6499
6518
6500
6519
if (!ToT || ToT == PT_Ptr) {
6501
6520
if (!this ->emitBitCastPtr (E))
0 commit comments