[PATCH] D23306: Fix bug in DAGBuilder for getelementptr with expanded vector.

Ayman Musa via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 9 03:53:00 PDT 2016


aymanmus created this revision.
aymanmus added reviewers: delena, mkuper.
aymanmus added a subscriber: llvm-commits.

Replacing the usage of MVT with EVT in case the vector type is expanded.

https://reviews.llvm.org/D23306

Files:
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  test/CodeGen/X86/gep-expanded-vector.ll

Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3330,8 +3330,9 @@
         if (CI->isZero())
           continue;
         APInt Offs = ElementSize * CI->getValue().sextOrTrunc(PtrSize);
+        LLVMContext &Context = *DAG.getContext();
         SDValue OffsVal = VectorWidth ?
-          DAG.getConstant(Offs, dl, MVT::getVectorVT(PtrTy, VectorWidth)) :
+          DAG.getConstant(Offs, dl, EVT::getVectorVT(Context, PtrTy, VectorWidth)) :
           DAG.getConstant(Offs, dl, PtrTy);
 
         // In an inbouds GEP with an offset that is nonnegative even when
Index: test/CodeGen/X86/gep-expanded-vector.ll
===================================================================
--- test/CodeGen/X86/gep-expanded-vector.ll
+++ test/CodeGen/X86/gep-expanded-vector.ll
@@ -0,0 +1,10 @@
+; RUN: llc < %s -O2 -mcpu=skx
+
+%struct.S1 = type { %struct.S1*, %struct.S1* }
+
+define void @malloc_init_state() unnamed_addr {
+entry:
+  %VectorGep7 = getelementptr inbounds %struct.S1*, <64 x %struct.S1**> undef, i64 -2
+  ret void
+}
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23306.67314.patch
Type: text/x-patch
Size: 1234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160809/0dcbe104/attachment.bin>


More information about the llvm-commits mailing list