> 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.
To fix this, I'd vastly prefer that you add TargetData::getTypeSizeInBits, rather than adding special cases for variable width integers (the current special case for bool is already bad). Change this code (line 8189): if (((SrcPTy->isInteger() && SrcPTy != Type::Int1Ty) || isa<PointerType>(SrcPTy)) && IC.getTargetData().getTypeSize(SrcPTy) == IC.getTargetData().getTypeSize(DestPTy)) { In any case, with either change, you can take out the "&& SrcPTy != Type::Int1Ty" check. The same xform happens for load, FWIW. It should be fixed also. -Chris > > > --- > Diffs of the changes: (+4 -3) > > InstructionCombining.cpp | 7 ++++--- > 1 files changed, 4 insertions(+), 3 deletions(-) > > > Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp > diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.604 > llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.605 > --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.604 Fri > Jan 19 15:13:56 2007 > +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Jan 19 > 15:20:31 2007 > @@ -8162,7 +8162,7 @@ > 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)); > @@ -8206,8 +8206,9 @@ > 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); > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits