-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-131798: JIT: Split CALL_TUPLE_1 into several uops #132851
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
Conversation
if (sym_matches_type(arg, &PyTuple_Type)) { | ||
// e.g. tuple((1, 2)) or tuple(foo) where foo is known to be a tuple | ||
res = arg; | ||
} |
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.
Same optimization as in #132849 (comment)
x = 0 | ||
for _ in range(n): | ||
y = tuple((1, 2)) # tuple argument | ||
a, _ = y # _UNPACK_SEQUENCE_TWO_TUPLE |
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 needed to use UNPACK_SEQUENCE(_TWO)_TUPLE
here since it is currently the only uop that propagates the tuple items to the result.
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.
Nice observation. Seems like _BINARY_OP_SUBSCR_TUPLE_INT
could be taught how to do this pretty easily for a constant RHS. Want to add that to your queue?
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.
It's already in the queue 😄
CALL_TUPLE_1
is equivalent totuple(...)
.Very similar to previous work on splitting up
CALL_TYPE_1
: #132419This splits the instruction into a smaller instruction + 2 guards which can be optimized away. This also sets the return type to
tuple
.