return 0;
}
-/// InstCombineStoreToCast - Fold 'store V, (cast P)' -> store (cast V), P'
+/// InstCombineStoreToCast - Fold store V, (cast P) -> store (cast V), P
/// when possible.
static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) {
User *CI = cast<User>(SI.getOperand(1));
if (isa<PointerType>(SIOp0->getType()))
opcode = Instruction::PtrToInt;
else if (const IntegerType* SITy = dyn_cast<IntegerType>(CastSrcTy))
- assert(DITy->getBitWidth() == SITy->getBitWidth() &&
- "Illegal store instruction");
+ if (SITy->getBitWidth() != DITy->getBitWidth())
+ return 0; // Don't do this transform on unequal bit widths.
+ // else, BitCast is fine
}
if (Constant *C = dyn_cast<Constant>(SIOp0))
NewCast = ConstantExpr::getCast(opcode, C, CastDstTy);