@@ -488,14 +488,25 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
488
488
if (DiscardResult)
489
489
return this ->discard (SubExpr);
490
490
491
- assert (Initializing); // FIXME: Not always correct.
491
+ if (!Initializing) {
492
+ std::optional<unsigned > LocalIndex = allocateLocal (CE);
493
+ if (!LocalIndex)
494
+ return false ;
495
+ if (!this ->emitGetPtrLocal (*LocalIndex, CE))
496
+ return false ;
497
+ }
498
+
492
499
const auto *VT = CE->getType ()->getAs <VectorType>();
493
- PrimType ElemT = classifyPrim (SubExpr);
500
+ PrimType ElemT = classifyPrim (SubExpr-> getType () );
494
501
unsigned ElemOffset = allocateLocalPrimitive (
495
502
SubExpr, ElemT, /* IsConst=*/ true , /* IsExtended=*/ false );
496
503
504
+ // Prepare a local variable for the scalar value.
497
505
if (!this ->visit (SubExpr))
498
506
return false ;
507
+ if (classifyPrim (SubExpr) == PT_Ptr && !this ->emitLoadPop (ElemT, CE))
508
+ return false ;
509
+
499
510
if (!this ->emitSetLocal (ElemT, ElemOffset, CE))
500
511
return false ;
501
512
@@ -2778,6 +2789,7 @@ template <class Emitter>
2778
2789
bool ByteCodeExprGen<Emitter>::VisitExtVectorElementExpr(
2779
2790
const ExtVectorElementExpr *E) {
2780
2791
const Expr *Base = E->getBase ();
2792
+ assert (Base->getType ()->isVectorType ());
2781
2793
2782
2794
SmallVector<uint32_t , 4 > Indices;
2783
2795
E->getEncodedElementAccess (Indices);
0 commit comments