This patch adds canonicalization for fir.store - the store operation is
eliminated when it is right next to a load from the same address.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Please wait for a review from the FIR team.
I will just make a note in passing that there is a fir-memref-datflow-opt that does some load to store forwarding and store removal in flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp. But that pass is probably not handling the cases here.
Please wait for a review from the FIR team.
Sure. It would be great if you could add some relevant reviewers as I am not aware who should review this except the already added ones.
there is a fir-memref-datflow-opt that does some load to store forwarding and store removal in flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp. But that pass is probably not handling the cases here.
I do not know about them. I will check out what they do, but with the current HEAD, these stores were not getting eliminated - that is correct.
Kiran makes a good point that there is a strong desire to perform a true mem-to-reg translation on FIR which would eliminate dead stores and register promote memory traffic to stack slots, etc.
It's not clear to me that there is a lot of IR that is simply the back-to-back Op pattern of:
%1 = fir.load %addr fir.store %1 to %addr
flang/lib/Optimizer/Dialect/FIROps.cpp | ||
---|---|---|
3035 | This seems like an extremely narrow application of dead-store removal. Does it actually fire all that much? |
there is a strong desire to perform a true mem-to-reg translation on FIR
Now that I think about it, this elimination is too special and it would be covered more effectively in a mem2reg kind of pass. Would make more sense to improve that instead of adding it separately. I will abandon this change and maybe work on that later.
This seems like an extremely narrow application of dead-store removal. Does it actually fire all that much?