[PATCH] D124459: [InstCombine] Combine opaque pointer GEPs with mismatching element types

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 26 12:03:09 PDT 2022


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:2067
+    if (!Offset.isZero() || (!IsFirstType && !ConstIndices[0].isZero()))
+      return nullptr;
+
----------------
aeubanks wrote:
> do we want to skip the transform after this if any of this fails?
I think it's fine to skip it, because this one should always be more powerful (for the "all constant GEP" subset it handles). At least that was the intention, maybe I'm overlooking some edge case.


================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:2070
+    SmallVector<Value *> Indices;
+    append_range(Indices, drop_end(Src->indices(),
+                                   Src->getNumIndices() - NumVarIndices));
----------------
aeubanks wrote:
> I'm surprised we don't have some sort of `first_n`
Yeah, I went looking for that one as well. There is `take_front` on `indexed_accessor_range`, but there doesn't seem to be anything generic currently.


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

https://reviews.llvm.org/D124459



More information about the llvm-commits mailing list