@@ -401,14 +401,16 @@ static Value *promoteAllocaUserToVector(
401
401
// We're loading the full vector.
402
402
Type *AccessTy = Inst->getType ();
403
403
TypeSize AccessSize = DL.getTypeStoreSize (AccessTy);
404
- if (AccessSize == VecStoreSize && cast<Constant>(Index)->isZeroValue ()) {
405
- if (AccessTy->isPtrOrPtrVectorTy ())
406
- CurVal = CreateTempPtrIntCast (CurVal, AccessTy);
407
- else if (CurVal->getType ()->isPtrOrPtrVectorTy ())
408
- CurVal = CreateTempPtrIntCast (CurVal, CurVal->getType ());
409
- Value *NewVal = Builder.CreateBitOrPointerCast (CurVal, AccessTy);
410
- Inst->replaceAllUsesWith (NewVal);
411
- return nullptr ;
404
+ if (Constant *CI = dyn_cast<Constant>(Index)) {
405
+ if (CI->isZeroValue () && AccessSize == VecStoreSize) {
406
+ if (AccessTy->isPtrOrPtrVectorTy ())
407
+ CurVal = CreateTempPtrIntCast (CurVal, AccessTy);
408
+ else if (CurVal->getType ()->isPtrOrPtrVectorTy ())
409
+ CurVal = CreateTempPtrIntCast (CurVal, CurVal->getType ());
410
+ Value *NewVal = Builder.CreateBitOrPointerCast (CurVal, AccessTy);
411
+ Inst->replaceAllUsesWith (NewVal);
412
+ return nullptr ;
413
+ }
412
414
}
413
415
414
416
// Loading a subvector.
@@ -456,12 +458,14 @@ static Value *promoteAllocaUserToVector(
456
458
// We're storing the full vector, we can handle this without knowing CurVal.
457
459
Type *AccessTy = Val->getType ();
458
460
TypeSize AccessSize = DL.getTypeStoreSize (AccessTy);
459
- if (AccessSize == VecStoreSize && cast<Constant>(Index)->isZeroValue ()) {
460
- if (AccessTy->isPtrOrPtrVectorTy ())
461
- Val = CreateTempPtrIntCast (Val, AccessTy);
462
- else if (VectorTy->isPtrOrPtrVectorTy ())
463
- Val = CreateTempPtrIntCast (Val, VectorTy);
464
- return Builder.CreateBitOrPointerCast (Val, VectorTy);
461
+ if (Constant *CI = dyn_cast<Constant>(Index)) {
462
+ if (CI->isZeroValue () && AccessSize == VecStoreSize) {
463
+ if (AccessTy->isPtrOrPtrVectorTy ())
464
+ Val = CreateTempPtrIntCast (Val, AccessTy);
465
+ else if (VectorTy->isPtrOrPtrVectorTy ())
466
+ Val = CreateTempPtrIntCast (Val, VectorTy);
467
+ return Builder.CreateBitOrPointerCast (Val, VectorTy);
468
+ }
465
469
}
466
470
467
471
// Storing a subvector.
0 commit comments