From 31a4ef4dc19b0c04c243cb2485d0a6cd44d799eb Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Mon, 22 Jan 2007 05:51:25 +0000 Subject: [PATCH] Cleanup checks in the load and store of casted pointer transforms. Two changes: (1) don't special case for i1 any more, (2) use the new TargetData::getTypeSizeInBits method to ensure source and dest are the same bit width. llvm-svn: 33427 --- .../Transforms/Scalar/InstructionCombining.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index a87a8ad575c6..d38c7c46c2ce 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -7990,8 +7990,8 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI) { if (const PointerType *SrcTy = dyn_cast(CastOp->getType())) { const Type *SrcPTy = SrcTy->getElementType(); - if ((DestPTy->isInteger() && DestPTy != Type::Int1Ty) || - isa(DestPTy) || isa(DestPTy)) { + if (DestPTy->isInteger() || isa(DestPTy) || + isa(DestPTy)) { // If the source is an array, the code below will not succeed. Check to // see if a trivial 'gep P, 0, 0' will help matters. Only do this for // constants. @@ -8004,13 +8004,13 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI) { SrcPTy = SrcTy->getElementType(); } - if (((SrcPTy->isInteger() && SrcPTy != Type::Int1Ty) || - isa(SrcPTy) || isa(SrcPTy)) && + if ((SrcPTy->isInteger() || isa(SrcPTy) || + isa(SrcPTy)) && // Do not allow turning this into a load of an integer, which is then // casted to a pointer, this pessimizes pointer analysis a lot. (isa(SrcPTy) == isa(LI.getType())) && - IC.getTargetData().getTypeSize(SrcPTy) == - IC.getTargetData().getTypeSize(DestPTy)) { + 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 the load, cast @@ -8178,8 +8178,7 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) { if (const PointerType *SrcTy = dyn_cast(CastOp->getType())) { const Type *SrcPTy = SrcTy->getElementType(); - if ((DestPTy->isInteger() && DestPTy != Type::Int1Ty) || - isa(DestPTy)) { + if (DestPTy->isInteger() || isa(DestPTy)) { // If the source is an array, the code below will not succeed. Check to // see if a trivial 'gep P, 0, 0' will help matters. Only do this for // constants.