Skip to content

Commit 7692c52

Browse files
RKSimoncjdb
authored andcommitted
[DAG] visitTRUNCATE_USAT_U - use sd_match to match FP_TO_UINT_SAT pattern. NFC.
1 parent 61780e1 commit 7692c52

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14919,23 +14919,14 @@ SDValue DAGCombiner::visitTRUNCATE_USAT_U(SDNode *N) {
1491914919
EVT VT = N->getValueType(0);
1492014920
SDValue N0 = N->getOperand(0);
1492114921

14922-
std::function<SDValue(SDValue)> MatchFPTOINT = [&](SDValue Val) -> SDValue {
14923-
if (Val.getOpcode() == ISD::FP_TO_UINT)
14924-
return Val;
14925-
return SDValue();
14926-
};
14927-
14928-
SDValue FPInstr = MatchFPTOINT(N0);
14929-
if (!FPInstr)
14930-
return SDValue();
14922+
SDValue FPVal;
14923+
if (sd_match(N0, m_FPToUI(m_Value(FPVal))) &&
14924+
DAG.getTargetLoweringInfo().shouldConvertFpToSat(
14925+
ISD::FP_TO_UINT_SAT, FPVal.getValueType(), VT))
14926+
return DAG.getNode(ISD::FP_TO_UINT_SAT, SDLoc(N0), VT, FPVal,
14927+
DAG.getValueType(VT.getScalarType()));
1493114928

14932-
EVT FPVT = FPInstr.getOperand(0).getValueType();
14933-
if (!DAG.getTargetLoweringInfo().shouldConvertFpToSat(ISD::FP_TO_UINT_SAT,
14934-
FPVT, VT))
14935-
return SDValue();
14936-
return DAG.getNode(ISD::FP_TO_UINT_SAT, SDLoc(FPInstr), VT,
14937-
FPInstr.getOperand(0),
14938-
DAG.getValueType(VT.getScalarType()));
14929+
return SDValue();
1493914930
}
1494014931

1494114932
/// Detect patterns of truncation with unsigned saturation:

0 commit comments

Comments
 (0)