Skip to content

gh-131798: JIT: Optimize _CALL_TYPE_1 when the result is known #135194

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tomasr8
Copy link
Member

@tomasr8 tomasr8 commented Jun 5, 2025

Followup to #134369 (comment)

This completely removes _CALL_TYPE_1 when the abstract interpreter is able to deduce the result (by knowing the type of the argument).

For example, for something like type(42), we currently do

_LOAD_CONST_INLINE_BORROW (callable: type)
_PUSH_NULL
_LOAD_CONST_INLINE_BORROW (arg: 42)
_CALL_TYPE_1

Note that we still do the call even when we know the result.

In this PR, when the result is known, _CALL_TYPE_1 is replaced with _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW:

_LOAD_CONST_INLINE_BORROW (callable: type)
_PUSH_NULL
_LOAD_CONST_INLINE_BORROW (arg: 42)
- _CALL_TYPE_1
+ _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW (arg: int)

Thanks to some previous work on optimizing remove_unneeded_uops this becomes just:

_LOAD_CONST_INLINE_BORROW (arg: int)

that is, the entire call is replaced with a load.

@tomasr8
Copy link
Member Author

tomasr8 commented Jun 6, 2025

The test failures should be fixed by #135204, let me update main to make sure CI is all green :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants