This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Try to perform select => binop combines when conditional operations are available
Needs ReviewPublic

Authored by asb on Apr 25 2023, 10:08 AM.

Details

Summary

When condops aren't available, these transformations are performed in lowerSELECT or in a DAGCombine on RISCVISD::SELECT_CC. This patch performs the first two of these combines, which are unconditionally profitable when conditional operations are enabled.

I'm posting this for comment on the general approach of performing this transformation as a dagcombine on select, and get feedback on the desirability of performing it even when condops aren't available (right now it causes a slight regression in a couple of the tests in min-max.ll). There are obviously a number of other condops related regressions, but this seemed like a relatively easily separable initial step. I'll also note that it's not possible to remove this transformation from lowerSELECT (and just rely on the ISD::SELECT combine) without causing codegen regressions, because a select might be produced through legalisation and lowered before the dag combiner runs again.

Diff Detail

Event Timeline

asb created this revision.Apr 25 2023, 10:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2023, 10:08 AM
asb requested review of this revision.Apr 25 2023, 10:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2023, 10:08 AM

I had wondered if it made sense to handle Zicond/XventanaCondOps in LowerSelect by creating RISCV::CZERO_EQZ/CZERO_NEZ opcodes. Would cut down on the number of isel patterns.

asb added a comment.EditedApr 26 2023, 7:20 AM

I had wondered if it made sense to handle Zicond/XventanaCondOps in LowerSelect by creating RISCV::CZERO_EQZ/CZERO_NEZ opcodes. Would cut down on the number of isel patterns.

Thanks, that's not an option I'd explored but I like that it might provide more uniformity for the condops vs non-condops. Let me have a play with that alternative.

I had wondered if it made sense to handle Zicond/XventanaCondOps in LowerSelect by creating RISCV::CZERO_EQZ/CZERO_NEZ opcodes. Would cut down on the number of isel patterns.

Thanks, that's not an option I'd explored but I like that it might provide more uniformity for the condops vs non-condops. Let me have a play with that alternative.

Reverse ping. Any update on this?

evandro removed a subscriber: evandro.May 23 2023, 2:46 PM