[PATCH] D110246: [InstSimplify][InstCombine] Fold ptrtoint(gep i8 null, x) -> x

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 23 04:30:25 PDT 2021


lebedev.ri added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4682
+        // limited to cases where the result type matches the GEP index type.
+        if (GEP->getNumIndices() == 1 && GEP->getOperand(1)->getType() == Ty) {
+          // We also can't perform the fold if we need a type size multiplier.
----------------
arichardson wrote:
> lebedev.ri wrote:
> > https://godbolt.org/z/hTbv3qqGT
> Sorry, I don't quite understand what this link is showing. The base is not null and there is more than one GEP index so this transformation won't happen.
I'm saying that the precondition you want is that the only non-zero index must be the last one (+ stride check),
not that there must only be a single index.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110246



More information about the llvm-commits mailing list