@@ -845,6 +845,13 @@ namespace {
845
845
return TLI.isOperationLegalOrCustom(Opcode, VT, LegalOperations);
846
846
}
847
847
848
+ bool hasUMin(EVT VT) const {
849
+ auto LK = TLI.getTypeConversion(*DAG.getContext(), VT);
850
+ return (LK.first == TargetLoweringBase::TypeLegal ||
851
+ LK.first == TargetLoweringBase::TypePromoteInteger) &&
852
+ TLI.isOperationLegal(ISD::UMIN, LK.second);
853
+ }
854
+
848
855
public:
849
856
/// Runs the dag combiner on all nodes in the work list
850
857
void Run(CombineLevel AtLevel);
@@ -4253,10 +4260,7 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
4253
4260
4254
4261
// (sub x, (select (ult x, y), 0, y)) -> (umin x, (sub x, y))
4255
4262
// (sub x, (select (uge x, y), y, 0)) -> (umin x, (sub x, y))
4256
- auto LK = TLI.getTypeConversion(*DAG.getContext(), VT);
4257
- if ((LK.first == TargetLoweringBase::TypeLegal ||
4258
- LK.first == TargetLoweringBase::TypePromoteInteger) &&
4259
- TLI.isOperationLegal(ISD::UMIN, LK.second)) {
4263
+ if (hasUMin(VT)) {
4260
4264
SDValue Y;
4261
4265
if (sd_match(N1, m_OneUse(m_Select(m_SetCC(m_Specific(N0), m_Value(Y),
4262
4266
m_SpecificCondCode(ISD::SETULT)),
0 commit comments