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

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 23 04:31:46 PDT 2021


arichardson 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.
----------------
lebedev.ri wrote:
> 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.
Ah yes of course. Will update the patch. Right now that is only handled by the InstCombine follow-up (D110247)


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