[llvm] [DAG] Support saturated truncate (PR #99418)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 7 01:46:58 PDT 2024
================
@@ -14915,6 +14920,171 @@ SDValue DAGCombiner::visitEXTEND_VECTOR_INREG(SDNode *N) {
return SDValue();
}
+SDValue DAGCombiner::visitTRUNCATE_USAT(SDNode *N) {
+ EVT VT = N->getValueType(0);
+ SDValue N0 = N->getOperand(0);
+
+ std::function<SDValue(SDValue)> MatchFPTOINT = [&](SDValue Val) -> SDValue {
+ if (Val.getOpcode() == ISD::FP_TO_UINT)
+ return Val;
+ if (Val.getOpcode() == ISD::SMAX) {
+ for (unsigned I = 0; I < Val.getNumOperands(); I++)
+ if (SDValue Matched = MatchFPTOINT(Val.getOperand(I)))
+ return Matched;
+ }
----------------
davemgreen wrote:
Remove this SMAX part, it is not very obvious why it would be correct and I don't believe it should be needed to get the basics working.
(MatchFPTOINT could then probably be removed, if the check for ISD::FP_TO_UINT was moved where it is currently called).
https://github.com/llvm/llvm-project/pull/99418
More information about the llvm-commits
mailing list