New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Folding 'gep p, (q - p)' to q should check it is never used for loads & stores #43748
Comments
I'm not familiar with the rules on this, so just adding a few notes and others can decide what to do:
|
inttoptr disables a lot of optimizations in LLVM, because LLVM is quite conservative with this. So I would avoid those here.
Thanks for the pointers! The solution seems to be to leave those GEPs/ptrtoint alone in the IR, and do this optimization at a later step. I don't know if SDAG already has an assembly-like memory model or if it's still higher-level like LLVM IR. |
*** Bug llvm/llvm-bugzilla-archive#45444 has been marked as a duplicate of this bug. *** |
Fixed by https://reviews.llvm.org/D98588 |
There's a patch for the same issue in InstSimplify at https://reviews.llvm.org/D98611 as well. |
mentioned in issue llvm/llvm-bugzilla-archive#45444 |
mentioned in issue llvm/llvm-bugzilla-archive#48577 |
Extended Description
According to the GEP document:
https://llvm.org/docs/GetElementPtr.html#can-i-compute-the-distance-between-two-objects-and-add-that-value-to-one-address-to-compute-the-other-address
Replacing ‘gep p, (q - p)’ with q is invalid when it is used by memory access operations.
InstCombine and InstSimplify both do this.
llc gep.ll -o -
emits an optimized assembly, so SelDag or MIR seem to already have optimizations for these this pattern if my understanding is correct?The text was updated successfully, but these errors were encountered: