[PATCH] D26014: [ConstantFold] Get the correct vector type when folding a getelementptr instruction with vector indices

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 15:15:08 PDT 2016


majnemer added inline comments.


================
Comment at: lib/IR/ConstantFold.cpp:2065
       GEPTy = VectorType::get(GEPTy, VT->getNumElements());
+    // When the getelementptr has one of more vector indices, it will
+    // return a vector of pointers. We guarantee that all the vectors
----------------
one or more


================
Comment at: test/Transforms/InstCombine/gep-vector.ll:1-19
+; RUN: opt -instcombine %s -S | FileCheck %s
+
+; CHECK-LABEL: patatino
+; CHECK-NEXT: ret void
+define void @patatino() {
+  %el = getelementptr i64, <8 x i64*> undef, <8 x i64> undef
+  %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)
----------------
Can we test the folding more directly? Why do we need the gather call? Couldn't we just have the function `ReturnInst` contain the GEP `ConstantExpr`?


https://reviews.llvm.org/D26014





More information about the llvm-commits mailing list