[PATCH] D110247: [InstCombine] Fold ptrtoint(gep null) with a variable index
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 23 11:17:47 PDT 2021
nikic added a comment.
I think the right way to view this fold is a special case of `ptrtoint (gep p, o) - ptrtoint (gep p, o2)`, which is handled in OptimizePointerDifference(). This case is the special case where `p = null` and `o2 = 0`. Looking at that fold a) we support non-integral pointers, so I'd say it's fine to support them in all these folds as well and b) for the case where the GEP has one use, there are no limits on the number of variable offsets. This makes sense, because this arithmetic is happening anyway, GEPs just pretend they are simpler than they really are.
Rather than manually expanding the calculation, you can use EmitGEPOffset().
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110247/new/
https://reviews.llvm.org/D110247
More information about the llvm-commits
mailing list