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

Christopher Tetreault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 17 17:49:50 PDT 2020


ctetreau 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),
----------------
can this use `auto`?


================
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:
> can this use `auto`?
what is the change to iterators from indices buying us?


================
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() {
----------------
the old thing should still work right? And presumably it's testing some crash that happened, perhaps we should leave it alone?


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