Sync the order of Zvlsseg registers with vector registers to make allocation order consistent with the regular register classes.
This may reduce copies, but we haven't observed it yet.
Paths
| Differential D110250
[RISCV] Sync Zvlsseg register order as the same as vector registers. ClosedPublic Authored by HsiangKai on Sep 22 2021, 7:06 AM.
Details Summary Sync the order of Zvlsseg registers with vector registers to make allocation order consistent with the regular register classes. This may reduce copies, but we haven't observed it yet.
Diff Detail
Unit TestsFailed Event TimelineHerald added subscribers: StephenFan, vkmr, evandro and 27 others. · View Herald TranscriptSep 22 2021, 7:06 AM Comment Actions I see, the script was updated to use CHECK-NEXT. Can you pre-commit re-running the script then apply this patch on top? Comment Actions I think this is reasonable. I wonder if you have a small test that shows we can avoid copies this way. Unless I missed one case, the updates to the tests only show different registers being used (I understand they're small enough and copies are not a problem for them). Perhaps you can precommit a test that will have better code generation with this change? Comment Actions
Sorry for replying late. I have no way to create a small test case to demonstrate it. Register allocator is smart enough to avoid redundant copy. Herald added a subscriber: achieveartificialintelligence. · View Herald TranscriptOct 4 2021, 11:11 PM Comment Actions I'm not sure I've seen a test where this removed any copies yet. I asked Kai about the allocation order while investigating an extra copy, but this change did not remove the copy on that test. But I still think it makes sense to allocate registers in a consistent order. I've updated the commit message to not say that this definitely removes copies. Comment Actions Yeah I can see that a consistent order being the same is probably a good thing, even if we don't see COPYs being removed.
Comment Actions I am preparing another patch to reorder the allocation order as v8 to v23, v24 to v31, and v0 to v7. I am not sure if it is better or not. Just refer to GPR that it uses argument registers as the first priority allocation registers. I already forgot why the vector register allocation order starts from v25. Comment Actions
Comment Actions I'm not sure I am the best person to accept as I'm not super familiar with anything related to Zvlsseg. Sorry! Comment Actions LGTM other than the comment about adding a comment.
This revision is now accepted and ready to land.Oct 26 2021, 1:30 PM This revision was landed with ongoing or failed builds.Oct 27 2021, 10:35 PM Closed by commit rG7051f73d696e: [RISCV] Sync Zvlsseg register order as the same as vector registers. (authored by HsiangKai). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 374223 llvm/lib/Target/RISCV/RISCVRegisterInfo.td
llvm/test/CodeGen/RISCV/rvv/addi-scalable-offset.mir
llvm/test/CodeGen/RISCV/rvv/commuted-op-indices-regression.mir
llvm/test/CodeGen/RISCV/rvv/emergency-slot.mir
llvm/test/CodeGen/RISCV/rvv/frameindex-addr.ll
llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
llvm/test/CodeGen/RISCV/rvv/mask-reg-alloc.mir
llvm/test/CodeGen/RISCV/rvv/reg-coalescing.mir
llvm/test/CodeGen/RISCV/rvv/regalloc-fast-crash.ll
llvm/test/CodeGen/RISCV/rvv/rv32-spill-zvlsseg.ll
llvm/test/CodeGen/RISCV/rvv/rv64-spill-zvlsseg.ll
llvm/test/CodeGen/RISCV/rvv/tail-agnostic-impdef-copy.mir
llvm/test/CodeGen/RISCV/rvv/vloxseg-rv32.ll
llvm/test/CodeGen/RISCV/rvv/vloxseg-rv64.ll
llvm/test/CodeGen/RISCV/rvv/vlsegff-rv32-dead.ll
llvm/test/CodeGen/RISCV/rvv/vlsegff-rv64-dead.ll
llvm/test/CodeGen/RISCV/rvv/vluxseg-rv32.ll
llvm/test/CodeGen/RISCV/rvv/vluxseg-rv64.ll
llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.mir
llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.mir
llvm/test/CodeGen/RISCV/rvv/vsoxseg-rv32.ll
llvm/test/CodeGen/RISCV/rvv/vsoxseg-rv64.ll
llvm/test/CodeGen/RISCV/rvv/vsuxseg-rv32.ll
llvm/test/CodeGen/RISCV/rvv/vsuxseg-rv64.ll
llvm/test/CodeGen/RISCV/rvv/zvlsseg-copy.mir
llvm/test/CodeGen/RISCV/rvv/zvlsseg-spill.mir
|
Probably worth a comment explaining what this is doing.