Skip to content

Commit e6f6d07

Browse files
committed
[DAGCombiner][NFC] Refactor creating hasUMin
1 parent b46f16c commit e6f6d07

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,13 @@ namespace {
845845
return TLI.isOperationLegalOrCustom(Opcode, VT, LegalOperations);
846846
}
847847

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+
848855
public:
849856
/// Runs the dag combiner on all nodes in the work list
850857
void Run(CombineLevel AtLevel);
@@ -4253,10 +4260,7 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
42534260

42544261
// (sub x, (select (ult x, y), 0, y)) -> (umin x, (sub x, y))
42554262
// (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)) {
42604264
SDValue Y;
42614265
if (sd_match(N1, m_OneUse(m_Select(m_SetCC(m_Specific(N0), m_Value(Y),
42624266
m_SpecificCondCode(ISD::SETULT)),

0 commit comments

Comments
 (0)