Hi @nikic , @sebpop, @kasuga-fj ,
I wanted to discuss this:
The goal is to move away from the type-based/structural
getelementptr
(GEP) instruction, to aptradd
instruction, which does no more and no less than adding an offset to a pointer.
as Nikita wrote in his blogpost. The context I wanted to bring this up is loop-interchange and DependenceAnalysis, and we have discussed this a bit there already on those merge requests (for example here), but thought a separate thread might help to separating things out. More specifically, I am interested if we can come up with a short term and long term plan for this and if something along those lines would be acceptable or not.
Short-term
We would really like to get interchange enabled, but are now blocked on a corner case. In a nutshell the problem is: type punning in C/C++ results in valid IR that can confuse DependenceAnalysis in some cases. We could put a bandaid on it and fix it, but only if we are allowed to look at GEP->getSourceElementType()
. There is already one occurence of this in the delinearizer that you would like to see go away because of the GEP type-based direction that you are on, and now I am kind of asking if we can add one more. But again, I am really hoping that is a stopgap while we work on the longer term solution.
Longer-term
The type-based GEPs don’t provide any semantical information, except for delinearization. One way to look at this as follows: the type information that is going to disappear from the GEPs, will have to be reintroduced in another way. That’s what we are working on, but is a longer term thing. I.e., we want to emit type information in the front-end and picked up by the optimiser. For example, related but not the same thing: bound information for statically declared arrays, and assumes for accesses. We hope to have an RFC soon and a talk about this at this upcoming llvm dev conference. But the point is that this needs community review and discussions, and is going to take months (and quite a few I think). This means we would be blocked for all that time.
That’s why I am interested in exploring if a short term stopgap and longer term commitment to address the issue properly is a possibility. Please let me know what you think, if you have other ideas, or if I missed something.