[PATCH] D82061: [IR] Prefer scalar type for struct indexes in GEP constant expressions.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 17 18:54:49 PDT 2020


efriedma marked 2 inline comments as done.
efriedma added inline comments.


================
Comment at: llvm/lib/IR/Constants.cpp:2178
   ArgVec.push_back(C);
-  for (unsigned i = 0, e = Idxs.size(); i != e; ++i) {
+  generic_gep_type_iterator<Value* const*>
+    GTI = gep_type_begin(Ty, Idxs),
----------------
ctetreau wrote:
> ctetreau wrote:
> > can this use `auto`?
> what is the change to iterators from indices buying us?
I think this can use auto, yes.

The point of using the iterators is that they provide the isStruct() and isSequential() methods.


================
Comment at: llvm/test/Analysis/ConstantFolding/vectorgep-crash.ll:27
 ; CHECK-LABEL: @test
-; CHECK: ret <16 x i32*> getelementptr ([65 x %struct.A], [65 x %struct.A]* @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, <16 x i32> zeroinitializer)
+; CHECK: ret <16 x i32*> getelementptr ([65 x %struct.A], [65 x %struct.A]* @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, i32 0)
 define <16 x i32*> @test() {
----------------
ctetreau wrote:
> the old thing should still work right? And presumably it's testing some crash that happened, perhaps we should leave it alone?
I'm only changing the CHECK line, not the input IR


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82061/new/

https://reviews.llvm.org/D82061





More information about the llvm-commits mailing list