Skip to content

Commit fd50d94

Browse files
committed
[Constraint system] Move SIMD operator partitioning into disjunction partitioning
Continuing along my path to move application-independent partitioning rules into the common disjunction partitioning code.
1 parent b993c6e commit fd50d94

File tree

2 files changed

+18
-37
lines changed

2 files changed

+18
-37
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,6 +1996,7 @@ void ConstraintSystem::partitionDisjunction(
19961996
// end of the partitioning.
19971997

19981998
SmallVector<unsigned, 4> favored;
1999+
SmallVector<unsigned, 4> simdOperators;
19992000
SmallVector<unsigned, 4> disabled;
20002001
SmallVector<unsigned, 4> unavailable;
20012002

@@ -2035,6 +2036,22 @@ void ConstraintSystem::partitionDisjunction(
20352036
});
20362037
}
20372038

2039+
// Partition SIMD operators.
2040+
if (!TC.getLangOpts().SolverEnableOperatorDesignatedTypes &&
2041+
isOperatorBindOverload(Choices[0])) {
2042+
forEachChoice(Choices, [&](unsigned index, Constraint *constraint) -> bool {
2043+
if (!isOperatorBindOverload(constraint))
2044+
return false;
2045+
2046+
if (isSIMDOperator(constraint->getOverloadChoice().getDecl())) {
2047+
simdOperators.push_back(index);
2048+
return true;
2049+
}
2050+
2051+
return false;
2052+
});
2053+
}
2054+
20382055
// Local function to create the next partition based on the options
20392056
// passed in.
20402057
PartitionAppendCallback appendPartition =
@@ -2058,6 +2075,7 @@ void ConstraintSystem::partitionDisjunction(
20582075
});
20592076
appendPartition(favored);
20602077
appendPartition(everythingElse);
2078+
appendPartition(simdOperators);
20612079

20622080
// Now create the remaining partitions from what we previously collected.
20632081
appendPartition(unavailable);

lib/Sema/ConstraintSystem.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,40 +1371,6 @@ ConstraintSystem::getTypeOfMemberReference(
13711371
return { openedType, type };
13721372
}
13731373

1374-
/// If there are any SIMD operators in the overload set, partition the set so
1375-
/// that the SIMD operators come at the end.
1376-
static ArrayRef<OverloadChoice> partitionSIMDOperators(
1377-
ArrayRef<OverloadChoice> choices,
1378-
SmallVectorImpl<OverloadChoice> &scratch) {
1379-
// If the first element isn't an operator, none of them are.
1380-
if (!choices[0].isDecl() ||
1381-
!isa<FuncDecl>(choices[0].getDecl()) ||
1382-
!cast<FuncDecl>(choices[0].getDecl())->isOperator() ||
1383-
choices[0].getDecl()->getASTContext().LangOpts
1384-
.SolverEnableOperatorDesignatedTypes)
1385-
return choices;
1386-
1387-
// Check whether we have any SIMD operators.
1388-
bool foundSIMDOperator = false;
1389-
for (const auto &choice : choices) {
1390-
if (isSIMDOperator(choice.getDecl())) {
1391-
foundSIMDOperator = true;
1392-
break;
1393-
}
1394-
}
1395-
1396-
if (!foundSIMDOperator)
1397-
return choices;
1398-
1399-
scratch.assign(choices.begin(), choices.end());
1400-
std::stable_partition(scratch.begin(), scratch.end(),
1401-
[](const OverloadChoice &choice) {
1402-
return !isSIMDOperator(choice.getDecl());
1403-
});
1404-
1405-
return scratch;
1406-
}
1407-
14081374
Type ConstraintSystem::getEffectiveOverloadType(const OverloadChoice &overload,
14091375
bool allowMembers,
14101376
DeclContext *useDC) {
@@ -1524,9 +1490,6 @@ void ConstraintSystem::addOverloadSet(Type boundType,
15241490
return;
15251491
}
15261492

1527-
SmallVector<OverloadChoice, 4> scratchChoices;
1528-
choices = partitionSIMDOperators(choices, scratchChoices);
1529-
15301493
SmallVector<Constraint *, 4> overloads;
15311494

15321495
// As we do for other favored constraints, if a favored overload has been

0 commit comments

Comments
 (0)