From 67f827ce5ba1296db9051892b4a8e10920053933 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sat, 20 Jan 2007 23:35:48 +0000 Subject: [PATCH] Revise the store V, (cast P) -> store (cast V) -> P transform. We only want to do this if the src and destination types have the same bit width. This patch uses TargetData::getTypeSizeInBits() instead of making a special case for integer types and avoiding the transform if they don't match. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33414 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 04b06d28aa7..a87a8ad575c 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -8192,10 +8192,9 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) { SrcPTy = SrcTy->getElementType(); } - if (((SrcPTy->isInteger() && SrcPTy != Type::Int1Ty) || - isa(SrcPTy)) && - IC.getTargetData().getTypeSize(SrcPTy) == - IC.getTargetData().getTypeSize(DestPTy)) { + if ((SrcPTy->isInteger() || isa(SrcPTy)) && + IC.getTargetData().getTypeSizeInBits(SrcPTy) == + IC.getTargetData().getTypeSizeInBits(DestPTy)) { // Okay, we are casting from one integer or pointer type to another of // the same size. Instead of casting the pointer before @@ -8208,13 +8207,9 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) { if (isa(CastDstTy)) { if (CastSrcTy->isInteger()) opcode = Instruction::IntToPtr; - } else if (const IntegerType* DITy = dyn_cast(CastDstTy)) { + } else if (isa(CastDstTy)) { if (isa(SIOp0->getType())) opcode = Instruction::PtrToInt; - else if (const IntegerType* SITy = dyn_cast(CastSrcTy)) - 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);