-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Constraint solver] De-prioritize SIMD operators. #21231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Constraint solver] De-prioritize SIMD operators. #21231
Conversation
The new SIMD proposal introduced a number of new operators, the presence of which causes more "expression too complex" failures. Route around the problem by de-prioritizing those operators, visiting them only if no other operator could be chosen. This should limit the type checker performance cost of said operators to only those expressions that need them OR that already failed to type-check. Fixes rdar://problem/46541800.
@swift-ci please test |
@swift-ci please test source compatibility |
return false; | ||
|
||
auto func = dyn_cast<FuncDecl>(value); | ||
if (!func) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can combine two ifs into one !(func && function->isOperator())
, and same could be done for nominal using De Morgan's Law :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like breaking out the conditions here.
|
||
// Check whether we have any SIMD operators. | ||
bool foundSIMDOperator = false; | ||
for (const auto &choice : choices) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's actually worse to check if we have any simd operators and then sort, might be faster to simplify sort since there are not going to be thousands of operators anyway...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to avoid the malloc + copy for the common case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarification!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use llvm::find_if
to make it a bit smaller :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Unfortunately this means if simd
is included and used it would be slower because we'd check generic operators and other stuff first...
@swift-ci please test |
@swift-ci please test source compatibility |
Build failed |
@swift-ci please test |
@swift-ci please test source compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SIMDOperators changes LGTM.
a9b6c48
to
052d4c1
Compare
@swift-ci please test source compatibility |
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please test |
Build failed |
Build failed |
Build failed |
@swift-ci please test |
Previous failure was a spurious one from LLDB:
|
This optimization is safe and improves things a bit, so I'm going to go ahead and merge it. The more advanced hack in #21253 is also way more dicey, so I want to hold off on that. |
The new SIMD proposal introduced a number of new operators, the presence of
which causes more "expression too complex" failures. Route around the
problem by de-prioritizing those operators, visiting them only if no
other operator could be chosen. This should limit the type checker
performance cost of said operators to only those expressions that need
them OR that already failed to type-check.
Fixes rdar://problem/46541800.