Skip to content

Commit 95b47ae

Browse files
committed
[CSOptimizer] Reduce overload types before ranking
This would make sure that any same-type requirements to a concrete type are substituted with such types which is especially important for SIMD operators like `&{+, -}` because they have `Scalar == (U)Int*` requirements.
1 parent 40a41c8 commit 95b47ae

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Sema/CSOptimizer.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,14 @@ static void determineBestChoicesInContext(
780780
favorExactMatchesOnly = true;
781781
}
782782

783+
// This is important for SIMD operators in particular because
784+
// a lot of their overloads have same-type requires to a concrete
785+
// type: `<Scalar == (U)Int*>(_: SIMD*<Scalar>, ...) -> ...`.
786+
if (genericSig) {
787+
overloadType = overloadType->getReducedType(genericSig)
788+
->castTo<FunctionType>();
789+
}
790+
783791
double score = 0.0;
784792
unsigned numDefaulted = 0;
785793
for (unsigned paramIdx = 0, n = overloadType->getNumParams();

0 commit comments

Comments
 (0)