[PATCH] D138637: [InstCombine] Combine opaque pointer single index GEP and with src GEP by matching the types

krishna chaitanya sankisa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 16 20:20:14 PST 2023


skc7 added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:2112
+      NewIndices.clear();
+      NewIndices.append(Src->idx_begin(), Src->idx_end());
+      NewIndices.append(GEP.idx_begin(), GEP.idx_end());
----------------
nikic wrote:
> Don't we need to only drop the last zero from NewIndices? Consider something like `getelementptr [3 x [2 x [1 x float]]], ptr %p, i64 %x` followed by `getelementptr float, ptr %gep, i64 %y`. I think your current code will convert this into `getelementptr [3 x [2 x [1 x float]]], ptr %p, i64 %x, i64 %y`, while the correct result would be `getelementptr [3 x [2 x [1 x float]]], ptr %p, i64 %x, i64 0, i64 %y`.
Hi @nikic. I have made the changes to check if zeroes have been appended to NewIndices after types matching and if so, last zero will be erased and then GEP indices will be appended. Please review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138637



More information about the llvm-commits mailing list