Use the KnownBits icmp comparisons to determine when a ISD::UMIN/UMAX op is unnecessary should either op be known to be ULE/UGE than the other.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
One step at a time :-) The UMIN/UMAX support will help some USUBSAT matching I'm working on, also we don't have test coverage yet and I haven't gotten around to creating SMIN/SMAX tests yet.
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | ||
---|---|---|
1745 | I think this check can miss some opportunities because it is slightly asymmetrical. For example, with 4-bit numbers, if LHS = 110x and RHS = x100 then ule(LHS, RHS) will return None. However ult(LHS, RLHS) would return False, so you could optimise to RHS. It does seem a shame to have to call both ule and ult just to catch this case. I wonder if there is a better way to code it. |
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | ||
---|---|---|
1745 | Yeah, it seems a shame but we don't have good alternatives - adding the ult/ugt test as well doesn't improve any additional existing tests - I can add coverage if you want though? |
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | ||
---|---|---|
1745 | I'd appreciate it but I certainly won't insist. I think the current patch is fine as far as it goes. |
I think this check can miss some opportunities because it is slightly asymmetrical. For example, with 4-bit numbers, if LHS = 110x and RHS = x100 then ule(LHS, RHS) will return None. However ult(LHS, RLHS) would return False, so you could optimise to RHS.
It does seem a shame to have to call both ule and ult just to catch this case. I wonder if there is a better way to code it.