From 55af2b59bba38230c78f985dd6243d8f473c6ac8 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Fri, 19 Jan 2007 21:20:31 +0000 Subject: [PATCH] For this transform: store V, (cast P) -> store (cast V), P don't allow the transform if V and the pointer's element type are different width integer types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33371 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index fd6d23e28f1..414ae794b18 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -8162,7 +8162,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { 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(SI.getOperand(1)); @@ -8206,8 +8206,9 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) { if (isa(SIOp0->getType())) opcode = Instruction::PtrToInt; else if (const IntegerType* SITy = dyn_cast(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(SIOp0)) NewCast = ConstantExpr::getCast(opcode, C, CastDstTy);