[llvm] 8075576 - [DAG] visitTRUNCATE_USAT_U - use sd_match to match FP_TO_UINT_SAT pattern. NFC.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 23 08:39:58 PDT 2024


Author: Simon Pilgrim
Date: 2024-08-23T16:39:32+01:00
New Revision: 807557654a3c1c75b9ca3aedf8672805c7b441d4

URL: https://github.com/llvm/llvm-project/commit/807557654a3c1c75b9ca3aedf8672805c7b441d4
DIFF: https://github.com/llvm/llvm-project/commit/807557654a3c1c75b9ca3aedf8672805c7b441d4.diff

LOG: [DAG] visitTRUNCATE_USAT_U - use sd_match to match FP_TO_UINT_SAT pattern. NFC.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 11935cbc309f01..b27f06f94ff0e7 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -14919,23 +14919,14 @@ SDValue DAGCombiner::visitTRUNCATE_USAT_U(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;
-    return SDValue();
-  };
-
-  SDValue FPInstr = MatchFPTOINT(N0);
-  if (!FPInstr)
-    return SDValue();
+  SDValue FPVal;
+  if (sd_match(N0, m_FPToUI(m_Value(FPVal))) &&
+      DAG.getTargetLoweringInfo().shouldConvertFpToSat(
+          ISD::FP_TO_UINT_SAT, FPVal.getValueType(), VT))
+    return DAG.getNode(ISD::FP_TO_UINT_SAT, SDLoc(N0), VT, FPVal,
+                       DAG.getValueType(VT.getScalarType()));
 
-  EVT FPVT = FPInstr.getOperand(0).getValueType();
-  if (!DAG.getTargetLoweringInfo().shouldConvertFpToSat(ISD::FP_TO_UINT_SAT,
-                                                        FPVT, VT))
-    return SDValue();
-  return DAG.getNode(ISD::FP_TO_UINT_SAT, SDLoc(FPInstr), VT,
-                     FPInstr.getOperand(0),
-                     DAG.getValueType(VT.getScalarType()));
+  return SDValue();
 }
 
 /// Detect patterns of truncation with unsigned saturation:


        


More information about the llvm-commits mailing list