This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add DAG combine to fold (select C, (add X, Y), Y) -> (add (select C, X, 0), Y).
ClosedPublic

Authored by craig.topper on Dec 21 2022, 12:56 AM.

Details

Summary

Similar for sub, or, and xor. All ops that have 0 as a neutral value.
This is based on a similar tranform in InstCombine.

This allows us to remove some XVentanaCondOps patterns and
some code from DAGCombine for RISCVISD::SELECT_CC.

Diff Detail

Event Timeline

craig.topper created this revision.Dec 21 2022, 12:56 AM
craig.topper requested review of this revision.Dec 21 2022, 12:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 21 2022, 12:56 AM
asb accepted this revision.Dec 21 2022, 1:50 AM

Modulo minor feedback on a code comment (same applies for the patch title), this LGTM.

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
9640

This comment doesn't match the body of the function, as it handles sub/add/or/xor

This revision is now accepted and ready to land.Dec 21 2022, 1:50 AM

Update function comment.
Rebase on new tests

This revision was landed with ongoing or failed builds.Dec 21 2022, 10:58 AM
This revision was automatically updated to reflect the committed changes.