Skip to content

Commit d3f9541

Browse files
committed
Revert "[CSOptimizer] Favor SIMD related arithmetic operator choices if argument is SIMD<N> type"
This reverts commit c2f7451.
1 parent 0e239dd commit d3f9541

File tree

1 file changed

+5
-56
lines changed

1 file changed

+5
-56
lines changed

lib/Sema/CSOptimizer.cpp

Lines changed: 5 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,6 @@ void forEachDisjunctionChoice(
8585
}
8686
}
8787

88-
static bool isSIMDType(Type type) {
89-
auto *NTD = dyn_cast_or_null<StructDecl>(type->getAnyNominal());
90-
if (!NTD)
91-
return false;
92-
93-
auto typeName = NTD->getName().str();
94-
if (!typeName.startswith("SIMD"))
95-
return false;
96-
97-
return NTD->getParentModule()->getName().is("Swift");
98-
}
99-
100-
static bool isArithmeticOperatorOnSIMDProtocol(ValueDecl *decl) {
101-
if (!isSIMDOperator(decl))
102-
return false;
103-
104-
if (!decl->getBaseIdentifier().isArithmeticOperator())
105-
return false;
106-
107-
auto *DC = decl->getDeclContext();
108-
if (auto *P = DC->getSelfProtocolDecl()) {
109-
if (auto knownKind = P->getKnownProtocolKind())
110-
return *knownKind == KnownProtocolKind::SIMD;
111-
}
112-
113-
return false;
114-
}
115-
11688
} // end anonymous namespace
11789

11890
/// Given a set of disjunctions, attempt to determine
@@ -180,31 +152,18 @@ static void determineBestChoicesInContext(
180152
resultTypes.push_back(resultType);
181153
}
182154

183-
auto isViableOverload = [&](ValueDecl *decl) {
184-
// Allow standard arithmetic operator overloads on SIMD protocol
185-
// to be considered because we can favor them when then argument
186-
// is a known SIMD<N> type.
187-
if (isArithmeticOperatorOnSIMDProtocol(decl))
188-
return true;
189-
190-
// Don't consider generic overloads because we need conformance
191-
// checking functionality to determine best favoring, preferring
192-
// such overloads based only on concrete types leads to subpar
193-
// choices due to missed information.
194-
if (decl->getInterfaceType()->is<GenericFunctionType>())
195-
return false;
196-
197-
return true;
198-
};
199-
200155
// The choice with the best score.
201156
double bestScore = 0.0;
202157
SmallVector<std::pair<Constraint *, double>, 2> favoredChoices;
203158

204159
forEachDisjunctionChoice(
205160
cs, disjunction,
206161
[&](Constraint *choice, ValueDecl *decl, FunctionType *overloadType) {
207-
if (!isViableOverload(decl))
162+
// Don't consider generic overloads because we need conformance
163+
// checking functionality to determine best favoring, preferring
164+
// such overloads based only on concrete types leads to subpar
165+
// choices due to missed information.
166+
if (decl->getInterfaceType()->is<GenericFunctionType>())
208167
return;
209168

210169
if (overloadType->getNumParams() != argFuncType->getNumParams())
@@ -245,16 +204,6 @@ static void determineBestChoicesInContext(
245204
if (candidateType->isEqual(paramType)) {
246205
argScore = std::max(
247206
argScore, /*fromLiteral=*/candidate.second ? 0.3 : 1.0);
248-
continue;
249-
}
250-
251-
// If argument is SIMD<N> type i.e. SIMD1<...> it's appropriate
252-
// to favor of the overloads that are declared on SIMD protocol
253-
// and expect a particular `Scalar` if it's known.
254-
if (isSIMDType(candidateType) &&
255-
isArithmeticOperatorOnSIMDProtocol(decl)) {
256-
argScore = std::max(argScore, 1.0);
257-
continue;
258207
}
259208
}
260209

0 commit comments

Comments
 (0)