summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAyman Musa <ayman.musa@intel.com>2016-08-17 07:52:15 +0000
committerAyman Musa <ayman.musa@intel.com>2016-08-17 07:52:15 +0000
commit71b43c5c1da23235c3d9dfeedcaa1fa2edd5959d (patch)
treec45f66c0909fdbf9f4ac7320b870e5efe00fc30c
parent5f6d73b1fa782d6ecf495242040471d828b2fbed (diff)
downloadbcm5719-llvm-71b43c5c1da23235c3d9dfeedcaa1fa2edd5959d.tar.gz
bcm5719-llvm-71b43c5c1da23235c3d9dfeedcaa1fa2edd5959d.zip
Fix bug in DAGBuilder for getelementptr with expanded vector.
Replacing the usage of MVT with EVT in case the vector type is expanded. Differential Revision: https://reviews.llvm.org/D23306 llvm-svn: 278913
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp3
-rw-r--r--llvm/test/CodeGen/X86/gep-expanded-vector.ll24
2 files changed, 26 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index b68b74e9ac9..4ba31cd3a9e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3329,8 +3329,9 @@ void SelectionDAGBuilder::visitGetElementPtr(const User &I) {
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
diff --git a/llvm/test/CodeGen/X86/gep-expanded-vector.ll b/llvm/test/CodeGen/X86/gep-expanded-vector.ll
new file mode 100644
index 00000000000..df21832b484
--- /dev/null
+++ b/llvm/test/CodeGen/X86/gep-expanded-vector.ll
@@ -0,0 +1,24 @@
+; RUN: llc < %s -O2 -mattr=avx512f -mtriple=x86_64-unknown | 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]]
+
+
OpenPOWER on IntegriCloud