llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Useless copies of x0 (zero) to registers used in branch comparisons without ISel patterns explicitly selecting X0

Open asb opened this issue 4 years ago • 4 comments

See D130809 for the patch to work around this in the RISC-V backend by adding additional ISel patterns. As noted by @topperc, the register coalescer doesn't always seem to succeed in doing this, when really it should.

Creating this issue to track the problem, as it would be nice to be able to remove these patterns at a later point if the problem can be identified and resolved.

asb avatar Aug 02 '22 08:08 asb

@llvm/issue-subscribers-backend-risc-v

llvmbot avatar Aug 02 '22 08:08 llvmbot

@arichardson noted another case where this seems to be happening in the in-tree tests.

asb avatar Aug 17 '22 12:08 asb

Some of the lit test cases that show this have multiple selects being expanded in the same basic block. These end up expanding into phis that use an x0 copy from a basic block that isn't an immediate predecessor of the phi.

topperc avatar Aug 18 '22 18:08 topperc

Opened #243484 with a fix and regression tests for RISC-V and AArch64

MaxGud10 avatar Nov 17 '26 21:11 MaxGud10