[llvm-dev] Opaque pointers and i8 GEPs
David Chisnall via llvm-dev
llvm-dev at lists.llvm.org
Sat Sep 4 06:08:41 PDT 2021
On 4 Sep 2021, at 10:17, Nikita Popov via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> My proposal here is that in opaque pointers mode, LLVM should consider i8 GEPs canonical for GEPs with constant offsets. We should not attempt to "guess" a good GEP type to use, and we should not try to generate complex GEP structures if a simple one will do. I don't think there's really any disadvantages to this, apart from the fact that it makes the discrepancy between typed and opaque pointer mode larger.
I completely agree. Eventually, I’d like GEP to lose the ability to have multiple type arguments and I think this is a good first step in that direction:
1. Always generate GEPs with i8 offsets with all address calculation in the arithmetic leading up to the operation.
2. Canonicalise all other GEPs to this form.
3. Remove support for other kinds of GEP.
In the back end, a GEP is just a {PTR} + {expression that evaluates to an integer} add operation. That’s what it looks like in any target and it’s the most that we guarantee about memory in the IR, so everything that looks as if it supports more than this adds complexity for no benefit. It also means that we sometimes miss optimisation opportunities because GEPs can encode complex arithmetic expressions that are not CSE’d because they’re a separate and special kind of arithmetic.
David
More information about the llvm-dev
mailing list