Skip to content

Commit 79573fa

Browse files
committed
[RISCV] Support umin/umax in tryFoldSelectIntoOp
The neutral values for these are -1U, and 0 respectively. We already have good arithmetic lowerings for selects with one arm equal to these values. smin/smax are a bit harder, and will be a separate change. Somewhat surprisingly, this looks to be a net code improvement in all of the configurations. With both zbb, it's a clear win. With only zicond, we still seem to come out ahead because we reduce the number of ziconds needed (since we lower min/max to them). Without either zbb or zicond, we're a bit more of wash, but the available arithmetic sequences are good enough that doing the select unconditionally before using branches for the min/max is probably still worthwhile?
1 parent 2fcbd33 commit 79573fa

File tree

2 files changed

+282
-440
lines changed

2 files changed

+282
-440
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18835,6 +18835,8 @@ static SDValue tryFoldSelectIntoOp(SDNode *N, SelectionDAG &DAG,
1883518835
case ISD::ADD:
1883618836
case ISD::OR:
1883718837
case ISD::XOR:
18838+
case ISD::UMIN:
18839+
case ISD::UMAX:
1883818840
break;
1883918841
}
1884018842

0 commit comments

Comments
 (0)