On 9/18/23 21:37, Vineet Gupta wrote:
On 9/18/23 19:41, Jeff Law wrote:
On 9/18/23 13:45, Vineet Gupta wrote:


For the cases which do require sign extends, but not being eliminated due to "missing definition(s)" I'm working on adapting Ajit's REE ABI interfaces work [2] to work for RISC-V as well.
I wonder if we could walk the DECL_ARGUMENTS for current_function_decl and create sign extensions for integer arguments smaller than XLEN at the start of the function.  Record them in a list.

Then we just let the rest of REE do its thing.  When REE is done we go back and delete those sign extensions we created.

Forgot to add that even if we were to do this (and the test is doing this already), REE would fail anyways. It does DF use/def traversal - starting with use in an extension insn and finding the defs. If the def was implicit - as in a function arg, it bails out. This is essentially what Ajit is trying to fix by identifying the def as a potential function arg and not bailing.

Right. What I'm suggesting is to create an explicit extension in the IL at the very beginning of REE for the appropriate arguments. Put the extension in the entry block.

That would make extensions that were previously in the RTL redundant allowing REE to remove them.

Then we also remove the explicitly added extensions.

Think of the extensions we're adding as expressing the the extension that the caller would have done and would expose the redundant extensions in the callee. We put them in the IL merely to make the existing REE algorithm happy. Once they've served their purpose in exposing redundant extensions we remove the ones we added.

If you're familiar with DSE there's a lot of similarities with how we discover dead stores into the stack. We pretend there's a store to each local frame slot in the epilogue, that in turn exposes stores into the local frame that would never be read because we're exiting the function.

Jeff

Reply via email to