Skip to content

(opt): skip specializing calls that would be inlined - #10350

Merged
orizi merged 1 commit into
mainfrom
orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline
Aug 31, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline

Conversation

@orizi

@orizi orizi commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

During the interleaved inlining/const-folding pass, a call with constant
arguments to a function that would be inlined was first specialized - paying
a full casm size estimation of the specialized function in
priv_should_specialize - and the specialized function was then immediately
inlined anyway (a specialized function inherits its base's inline
configuration, and a small base's specialization is smaller yet). Inlining
the base directly and const folding in place reaches equivalent code without
the extra estimation and specialized function lowering.

Skip specialization for such calls. As every statement is checked for
inlining right after its const-folding visit, such calls are always inlined
by the interleaved pass and never survive to the standalone const-folding
pass.

Improves full-compilation time by ~4.5% (measured on top of the size
estimation memoization). Emitted code is equivalent: e2e and contract
outputs are unchanged, and debug locations lose a redundant self-inlining
frame.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

orizi commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author

@orizi
orizi force-pushed the orizi/08-14-_opt_inline_calls_appended_to_a_block_by_const_folding branch from 771a3b3 to caec800 Compare August 15, 2026 15:09
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from 5b93864 to 2364400 Compare August 15, 2026 15:09
@orizi
orizi force-pushed the orizi/08-14-_opt_inline_calls_appended_to_a_block_by_const_folding branch from caec800 to 6faccdd Compare August 16, 2026 10:20
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch 2 times, most recently from cd84957 to b7fd14d Compare August 16, 2026 10:36
@orizi
orizi force-pushed the orizi/08-14-_opt_inline_calls_appended_to_a_block_by_const_folding branch from 6faccdd to 7a3da04 Compare August 16, 2026 10:56
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from b7fd14d to 4a1a744 Compare August 16, 2026 10:56
@orizi
orizi changed the base branch from orizi/08-14-_opt_inline_calls_appended_to_a_block_by_const_folding to graphite-base/10350 August 25, 2026 07:54
@orizi
orizi force-pushed the graphite-base/10350 branch from 7a3da04 to 05e51e7 Compare August 25, 2026 07:58
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from 4a1a744 to c999b5f Compare August 25, 2026 07:58
@orizi
orizi changed the base branch from graphite-base/10350 to orizi/08-14-_opt_inline_calls_appended_to_a_block_by_const_folding August 25, 2026 07:58
@orizi
orizi changed the base branch from orizi/08-14-_opt_inline_calls_appended_to_a_block_by_const_folding to graphite-base/10350 August 25, 2026 08:00
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from c999b5f to b8836d0 Compare August 25, 2026 08:00
@orizi
orizi force-pushed the graphite-base/10350 branch from 05e51e7 to 1f2e292 Compare August 25, 2026 08:00
@orizi
orizi changed the base branch from graphite-base/10350 to orizi/08-14-_opt_inline_calls_appended_to_a_block_by_const_folding August 25, 2026 08:00
@orizi
orizi changed the base branch from orizi/08-14-_opt_inline_calls_appended_to_a_block_by_const_folding to graphite-base/10350 August 25, 2026 08:29
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from b8836d0 to 5d7bd37 Compare August 25, 2026 08:29
@orizi
orizi changed the base branch from graphite-base/10350 to orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants August 25, 2026 08:29
@orizi
orizi changed the base branch from orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants to graphite-base/10350 August 25, 2026 08:35
@orizi
orizi force-pushed the graphite-base/10350 branch from 155e76b to 55ed529 Compare August 25, 2026 08:36
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from 5d7bd37 to 0a63156 Compare August 25, 2026 08:36
@orizi
orizi changed the base branch from graphite-base/10350 to orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants August 25, 2026 08:36
@orizi
orizi changed the base branch from orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants to graphite-base/10350 August 25, 2026 08:59
@orizi
orizi changed the base branch from orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants to graphite-base/10350 August 25, 2026 10:01
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from 32c952b to d62c854 Compare August 25, 2026 10:01
@orizi
orizi force-pushed the graphite-base/10350 branch from 12dd24d to 2fc317e Compare August 25, 2026 10:01
@orizi
orizi changed the base branch from graphite-base/10350 to orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants August 25, 2026 10:01
@orizi
orizi changed the base branch from orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants to graphite-base/10350 August 25, 2026 10:14
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from d62c854 to c64d843 Compare August 25, 2026 10:15
@orizi
orizi force-pushed the graphite-base/10350 branch from 2fc317e to 9f80526 Compare August 25, 2026 10:15
@orizi
orizi changed the base branch from graphite-base/10350 to orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants August 25, 2026 10:15
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from c64d843 to 36d4262 Compare August 25, 2026 11:09
@orizi
orizi changed the base branch from orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants to graphite-base/10350 August 25, 2026 11:14
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from 36d4262 to c055ead Compare August 25, 2026 11:14
@orizi
orizi force-pushed the graphite-base/10350 branch from 9f80526 to b5698d6 Compare August 25, 2026 11:14
@orizi
orizi changed the base branch from graphite-base/10350 to orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants August 25, 2026 11:14
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from c055ead to 634bf8a Compare August 25, 2026 11:51
@orizi
orizi force-pushed the orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants branch from b5698d6 to bad7ba0 Compare August 25, 2026 11:52
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from 634bf8a to f59b422 Compare August 25, 2026 11:52

@TomerStarkware TomerStarkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@TomerStarkware reviewed 7 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from f59b422 to 6885e4e Compare August 31, 2026 08:57
@orizi
orizi force-pushed the orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants branch from bad7ba0 to a247eb6 Compare August 31, 2026 08:57

@TomerStarkware TomerStarkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomerStarkware reviewed 1 file and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

During the interleaved inlining/const-folding pass, a call with constant
arguments to a function that would be inlined was first specialized - paying
a full casm size estimation of the specialized function in
priv_should_specialize - and the specialized function was then immediately
inlined anyway (a specialized function inherits its base's inline
configuration, and a small base's specialization is smaller yet). Inlining
the base directly and const folding in place reaches equivalent code without
the extra estimation and specialized function lowering.

Skip specialization for such calls. As every statement is checked for
inlining right after its const-folding visit, such calls are always inlined
by the interleaved pass and never survive to the standalone const-folding
pass.

Improves full-compilation time by ~4.5% (measured on top of the size
estimation memoization). Emitted code is equivalent: e2e and contract
outputs are unchanged, and debug locations lose a redundant self-inlining
frame.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@orizi
orizi changed the base branch from orizi/08-25-_opt_fold_struct_destructure_of_a_constant_into_member_constants to graphite-base/10350 August 31, 2026 10:15
@orizi
orizi force-pushed the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch from 6885e4e to e8db694 Compare August 31, 2026 10:15
@orizi
orizi force-pushed the graphite-base/10350 branch from a247eb6 to 6e4b96f Compare August 31, 2026 10:15
@orizi
orizi changed the base branch from graphite-base/10350 to main August 31, 2026 10:15
@orizi
orizi enabled auto-merge August 31, 2026 10:15
@orizi
orizi added this pull request to the merge queue Aug 31, 2026
Merged via the queue into main with commit cdaa757 Aug 31, 2026
106 checks passed
@orizi
orizi deleted the orizi/08-14-_opt_skip_specializing_calls_the_size_heuristic_would_inline branch August 31, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants