[PATCH] D142612: [RISCV][NFC] Add test for register coalescing x0

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 00:50:42 PST 2023


qcolombet added a comment.

Hi @luke,

> In both test cases, %0 is unable to be coalesced due to the fact that it has a "complex interval" with multiple values,

That's by design because for complex intervals, in theory, we wouldn't save any copies.
If you consider the general case:

     if
  1:   %0 = copy $reserved
     else
  2:   %0 = ... something else
  3: ... = %0

If we coalesce #1, because the interval is complex we know that at least part of the interval won't be able to use `$reserved` so we'll have to leave a `virtReg = copy $reserved` somewhere.

In your `f` case this is actually possible to completely eliminate all copies because all the definitions are a copy of that same register. We might want to support that in the coalescer, but that looks a bit too specific to be worth it but I could be wrong.
An alternative would be to check why CSE is not picking it up.

For your second case (`g`), what is putting the copy and the add in `bb.1` on the same live-interval?
If they were still separate, the copy you want to remove should be removed directly by the coalescer.

Assuming the issue is not created by the coalescer itself, I would suggest to fix that or consider running something similar to `RenameIndependentSubregs` to break the live-intervals that have been merge for no good reason.
Now if the issue is created by the coalescer itself, we'll need to dig more to see why we end up in this situation.

Cheers,
-Quentin


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142612



More information about the llvm-commits mailing list