Teach InstCombine visitGetElementPtr about address spaces

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188721 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Matt Arsenault
2013-08-19 22:17:40 +00:00
parent c4ad982f0b
commit 8e3367ea36
4 changed files with 54 additions and 21 deletions

View File

@ -1385,9 +1385,10 @@ Instruction *InstCombiner::commonPointerCastTransforms(CastInst &CI) {
GEP->accumulateConstantOffset(*TD, Offset)) {
// Get the base pointer input of the bitcast, and the type it points to.
Value *OrigBase = BCI->getOperand(0);
Type *GEPIdxTy = OrigBase->getType()->getPointerElementType();
SmallVector<Value*, 8> NewIndices;
if (FindElementAtOffset(GEPIdxTy, Offset.getSExtValue(), NewIndices)) {
if (FindElementAtOffset(OrigBase->getType(),
Offset.getSExtValue(),
NewIndices)) {
// If we were able to index down into an element, create the GEP
// and bitcast the result. This eliminates one bitcast, potentially
// two.