[PATCH] D31470: [InstCombine] Correct the check for vector GEPs

Matthew Simpson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 29 11:35:32 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL299017: [InstCombine] Correct the check for vector GEPs (authored by mssimpso).

Changed prior to commit:
  https://reviews.llvm.org/D31470?vs=93383&id=93394#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31470

Files:
  llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/trunk/test/Transforms/InstCombine/getelementptr.ll


Index: llvm/trunk/test/Transforms/InstCombine/getelementptr.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/getelementptr.ll
+++ llvm/trunk/test/Transforms/InstCombine/getelementptr.ll
@@ -931,4 +931,15 @@
   ret i32 addrspace(1)* %x
 }
 
+define <2 x i32*> @PR32414(i32** %ptr) {
+; CHECK-LABEL: @PR32414(
+; CHECK-NEXT:    [[TMP0:%.*]] = bitcast i32** %ptr to i32*
+; CHECK-NEXT:    [[TMP1:%.*]] = getelementptr inbounds i32, i32* [[TMP0]], <2 x i64> <i64 0, i64 1>
+; CHECK-NEXT:    ret <2 x i32*> [[TMP1]]
+;
+  %tmp0 = bitcast i32** %ptr to i32*
+  %tmp1 = getelementptr inbounds i32, i32* %tmp0, <2 x i64> <i64 0, i64 1>
+  ret <2 x i32*> %tmp1
+}
+
 ; CHECK: attributes [[NUW]] = { nounwind }
Index: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1655,14 +1655,14 @@
     }
   }
 
-  // Handle gep(bitcast x) and gep(gep x, 0, 0, 0).
-  Value *StrippedPtr = PtrOp->stripPointerCasts();
-  PointerType *StrippedPtrTy = dyn_cast<PointerType>(StrippedPtr->getType());
-
   // We do not handle pointer-vector geps here.
-  if (!StrippedPtrTy)
+  if (GEP.getType()->isVectorTy())
     return nullptr;
 
+  // Handle gep(bitcast x) and gep(gep x, 0, 0, 0).
+  Value *StrippedPtr = PtrOp->stripPointerCasts();
+  PointerType *StrippedPtrTy = cast<PointerType>(StrippedPtr->getType());
+
   if (StrippedPtr != PtrOp) {
     bool HasZeroPointerIndex = false;
     if (ConstantInt *C = dyn_cast<ConstantInt>(GEP.getOperand(1)))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31470.93394.patch
Type: text/x-patch
Size: 1713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170329/d0a75906/attachment.bin>


More information about the llvm-commits mailing list