Skip to content

Commit d75b837

Browse files
authored
[RISCV] Support umin/umax in tryFoldSelectIntoOp (#157548)
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 a848008 commit d75b837

File tree

2 files changed

+286
-436
lines changed

2 files changed

+286
-436
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18839,6 +18839,8 @@ static SDValue tryFoldSelectIntoOp(SDNode *N, SelectionDAG &DAG,
1883918839
case ISD::ADD:
1884018840
case ISD::OR:
1884118841
case ISD::XOR:
18842+
case ISD::UMIN:
18843+
case ISD::UMAX:
1884218844
break;
1884318845
}
1884418846

0 commit comments

Comments
 (0)