This is an archive of the discontinued LLVM Phabricator instance.

[RISCV]Keep (select c, 0/-1, X) during PerformDAGCombine
ClosedPublic

Authored by liaolucy on Dec 4 2022, 6:16 AM.

Details

Summary

D135833, lowerSelect: (select C, -1/0, X) -> or/and
Keep (select c, 0/-1, X), thus making better use of lowerSelect to eliminate branch instructions.

Diff Detail

Unit TestsFailed

Event Timeline

liaolucy created this revision.Dec 4 2022, 6:16 AM
liaolucy requested review of this revision.Dec 4 2022, 6:16 AM

Nothing about the title or commit message gives much of a glue about which existing transformation is being modified. There are quite a few select related optimizations. Can you give more detail?

llvm/test/CodeGen/RISCV/select-binop-identity.ll
1

Can you add new RUN lines with short forward branch enabled?

liaolucy updated this revision to Diff 480011.Dec 5 2022, 1:10 AM
liaolucy retitled this revision from Branchless optimization for select instructions to [RISCV]Keep (select c, 0/-1, X) during PerformDAGCombine.
liaolucy edited the summary of this revision. (Show Details)

add new RUN lines with -mcpu=sifive-u74

Try to add more optimization details

liaolucy marked an inline comment as done.Dec 5 2022, 1:25 AM
liaolucy added inline comments.
llvm/test/CodeGen/RISCV/select-binop-identity.ll
34

There is an extra instruction here, which seems to be caused by PseudoCCMOVGPR. I'll debug it more carefully, maybe a new patch is needed.

craig.topper added inline comments.Dec 5 2022, 3:29 PM
llvm/test/CodeGen/RISCV/select-binop-identity.ll
34

The short forward branch optimization does currently require a mv to be in shadow of the branch. Technically the hardware supports most ALU operations in the branch shadow, but that will likely require a pseudo instruction like PseudoCCMOVGPR for each ALU operation to express.

This revision is now accepted and ready to land.Dec 5 2022, 3:29 PM
This revision was automatically updated to reflect the committed changes.