From: Manuel Jacob Date: Wed, 16 Jul 2014 20:13:45 +0000 (+0000) Subject: Utilize CastInst::CreatePointerBitCastOrAddrSpaceCast here. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d6b31659a7578aca0a5140b9c915d8befc4ea815;p=oota-llvm.git Utilize CastInst::CreatePointerBitCastOrAddrSpaceCast here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213189 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index fe3b8b41fdb..d3648e2d050 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -1582,9 +1582,8 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { Builder->CreateGEP(StrippedPtr, Idx, GEP.getName()); // V and GEP are both pointer types --> BitCast - if (StrippedPtrTy->getAddressSpace() == GEP.getPointerAddressSpace()) - return new BitCastInst(NewGEP, GEP.getType()); - return new AddrSpaceCastInst(NewGEP, GEP.getType()); + return CastInst::CreatePointerBitCastOrAddrSpaceCast(NewGEP, + GEP.getType()); } // Transform things like: @@ -1616,9 +1615,8 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { Builder->CreateGEP(StrippedPtr, NewIdx, GEP.getName()); // The NewGEP must be pointer typed, so must the old one -> BitCast - if (StrippedPtrTy->getAddressSpace() == GEP.getPointerAddressSpace()) - return new BitCastInst(NewGEP, GEP.getType()); - return new AddrSpaceCastInst(NewGEP, GEP.getType()); + return CastInst::CreatePointerBitCastOrAddrSpaceCast(NewGEP, + GEP.getType()); } } } @@ -1658,9 +1656,8 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { Builder->CreateInBoundsGEP(StrippedPtr, Off, GEP.getName()) : Builder->CreateGEP(StrippedPtr, Off, GEP.getName()); // The NewGEP must be pointer typed, so must the old one -> BitCast - if (StrippedPtrTy->getAddressSpace() == GEP.getPointerAddressSpace()) - return new BitCastInst(NewGEP, GEP.getType()); - return new AddrSpaceCastInst(NewGEP, GEP.getType()); + return CastInst::CreatePointerBitCastOrAddrSpaceCast(NewGEP, + GEP.getType()); } } }