Can we have mixed integer and vector indices (langref doesn't seem to forbid it)? If so, what happens if the first one is an integer, and then you get a vector of indices?<div><br></div><div> Filipe<span></span><br><br>On Wednesday, 26 October 2016, Davide Italiano via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">davide created this revision.<br>
davide added reviewers: majnemer, Bigcheese, RKSimon, spatel.<br>
davide added a subscriber: llvm-commits.<br>
<br>
When we constant fold `getelementptr` and the indices are vector, the type created is `i64 *` and not `<8 x i64*>` which caseuse an assertion to fire in `replaceAllUsesWith`. I think it's OK just checking for the first index for the reason pointed out in the comment.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D26014" target="_blank">https://reviews.llvm.org/<wbr>D26014</a><br>
<br>
Files:<br>
  lib/IR/ConstantFold.cpp<br>
  test/Transforms/InstCombine/<wbr>gep-vector.ll<br>
<br>
<br>
Index: test/Transforms/InstCombine/<wbr>gep-vector.ll<br>
==============================<wbr>==============================<wbr>=======<br>
--- /dev/null<br>
+++ test/Transforms/InstCombine/<wbr>gep-vector.ll<br>
@@ -0,0 +1,19 @@<br>
+; RUN: opt -instcombine %s -S | FileCheck %s<br>
+<br>
+; CHECK-LABEL: patatino<br>
+; CHECK-NEXT: ret void<br>
+define void @patatino() {<br>
+  %el = getelementptr i64, <8 x i64*> undef, <8 x i64> undef<br>
+  %gather = call <8 x i64> @llvm.masked.gather.v8i64(<8 x i64*> %el, i32 8, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i64> undef)<br>
+  ret void<br>
+}<br>
+<br>
+; CHECK-LABEL: patatino2<br>
+; CHECK-NEXT: ret void<br>
+define void @patatino2() {<br>
+  %el = getelementptr inbounds i64, i64* undef, <8 x i64> undef<br>
+  %gather = call <8 x i64> @llvm.masked.gather.v8i64(<8 x i64*> %el, i32 8, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i64> undef)<br>
+  ret void<br>
+}<br>
+<br>
+declare <8 x i64> @llvm.masked.gather.v8i64(<8 x i64*>, i32, <8 x i1>, <8 x i64>)<br>
Index: lib/IR/ConstantFold.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- lib/IR/ConstantFold.cpp<br>
+++ lib/IR/ConstantFold.cpp<br>
@@ -2062,6 +2062,12 @@<br>
     Type *GEPTy = PointerType::get(Ty, PtrTy->getAddressSpace());<br>
     if (VectorType *VT = dyn_cast<VectorType>(C-><wbr>getType()))<br>
       GEPTy = VectorType::get(GEPTy, VT->getNumElements());<br>
+    // When the getelementptr has one of more vector indices, it will<br>
+    // return a vector of pointers. We guarantee that all the vectors<br>
+    // in this case will have the same width, so we can just look at<br>
+    // the first one.<br>
+    else if (VectorType *VT = dyn_cast<VectorType>(Idxs[0]-><wbr>getType()))<br>
+      GEPTy = VectorType::get(GEPTy, VT->getNumElements());<br>
     return UndefValue::get(GEPTy);<br>
   }<br>
<br>
<br>
<br>
</blockquote></div><br><br>-- <br>  F<br><br>