[PATCH] D138899: [PowerPC] add a peephole to eliminate unnecessary load

Roland Froese via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 12:09:14 PST 2022


RolandF added a comment.

There is an existing place in codegen to handle forwarding a store value to the corresponding load - ForwardStoreValueToDirectLoad in lib/CodeGen/SelectionDAG/DAGCombiner.cpp.  Handling this in codegen would not require putting the code in multiple places.  The code there is relatively simple - it just looks to see if the thing on the chain immediately before the load is the setting store.  For the first case in byval-lhs.ll there is a CALLSEQ_START on the chain in between the load and the store.  Maybe it is possible to look past that in the chain to see the store.  Since the load is for a call there may be a register copy required to replace the load.  Where there is a sequence of multiple stores followed by multiple loads it would require looking back in the chain past loads and past stores to fixed stack locations that do not overlap.  I don't know if that is allowed, but in theory it could work.

I would suggest to discuss offline with @nemanjai if such an approach is viable and preferred.  If not, I think that is a reasonable argument for an MIR level approach.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138899/new/

https://reviews.llvm.org/D138899



More information about the llvm-commits mailing list