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

Ayman Musa via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 14 01:30:48 PDT 2016


aymanmus updated this revision to Diff 67973.
aymanmus added a comment.

Updating the test to actually check that code is emitted with right address calculation.


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,24 @@
+; RUN: llc < %s -O2 -mattr=avx512f | FileCheck %s
+
+%struct.S1 = type { %struct.S1*, %struct.S1* }
+
+define %struct.S1** @malloc_init_state(<64 x %struct.S1**> %tmp, i32 %ind) {
+entry:
+  %Vec = getelementptr inbounds %struct.S1*, <64 x %struct.S1**> %tmp , i64 2
+  %ptr = extractelement <64 x %struct.S1**> %Vec, i32 %ind
+  ret %struct.S1** %ptr
+}
+
+; CHECK: .LCPI0_0:
+; CHECK: .quad 16
+; CHECK: vpbroadcastq    .LCPI0_0(%rip), [[Z1:%zmm[0-9]]]
+; CHECK-NEXT: vpaddq  [[Z1]], [[Z2:%zmm[0-9]]], [[Z2]]
+; CHECK-NEXT: vpaddq  [[Z1]], [[Z3:%zmm[0-9]]], [[Z3]]
+; CHECK-NEXT: vpaddq  [[Z1]], [[Z4:%zmm[0-9]]], [[Z4]]
+; CHECK-NEXT: vpaddq  [[Z1]], [[Z5:%zmm[0-9]]], [[Z5]]
+; CHECK-NEXT: vpaddq  [[Z1]], [[Z6:%zmm[0-9]]], [[Z6]]
+; CHECK-NEXT: vpaddq  [[Z1]], [[Z7:%zmm[0-9]]], [[Z7]]
+; CHECK-NEXT: vpaddq  [[Z1]], [[Z8:%zmm[0-9]]], [[Z8]]
+; CHECK-NEXT: vpaddq  [[Z1]], [[Z9:%zmm[0-9]]], [[Z9]]
+
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23306.67973.patch
Type: text/x-patch
Size: 1912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160814/32513d3a/attachment.bin>


More information about the llvm-commits mailing list