Skip to content
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

MIR inliner, despite running, doesn't always inline trivial things like i32::le #138136

Closed
scottmcm opened this issue Mar 7, 2025 · 0 comments · Fixed by #138157
Closed

MIR inliner, despite running, doesn't always inline trivial things like i32::le #138136

scottmcm opened this issue Mar 7, 2025 · 0 comments · Fixed by #138157
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining needs-triage This issue may need triage. Remove it if it has been sufficiently triaged.

Comments

@scottmcm
Copy link
Member

scottmcm commented Mar 7, 2025

IIRC this is due to top-down inlining restrictions, but we should find a way to ensure those restrictions don't apply to things like <i32 as PartialOrd>::le which are just a single MIR statement and therefore it's always profitable to inline them, no matter what.

See https://github.com/rust-lang/rust/pull/138135/files#diff-7f0e93ee8770e4ffe714ae19c6f0f3ab6ae1bc76e3fb03f079e11988fbbab93eR58 for an example.

Alternatively we could consider InstSimplifying them, like we do clone calls on primitives.

@scottmcm scottmcm added A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining labels Mar 7, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 7, 2025
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 7, 2025
…<try>

Allow more top-down inlining for single-BB callees

This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if
we've already done a bunch of inlining to find the calls to them.

Fixes rust-lang#138136

Draft as it's built atop rust-lang#138135, which adds a mir-opt test that's a nice demonstration of this.
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 8, 2025
…<try>

Allow more top-down inlining for single-BB callees

This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if
we've already done a bunch of inlining to find the calls to them.

Fixes rust-lang#138136

~~Draft as it's built atop rust-lang#138135, which adds a mir-opt test that's a nice demonstration of this.  To see just this change, look at <https://github.com/rust-lang/rust/pull/138157/commits/48f63e3be552605c2933056b77bf23a326757f92>~~ Rebased to be just the inlining change, as the other existing tests show it great.
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 9, 2025
…<try>

Allow more top-down inlining for single-BB callees

This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if
we've already done a bunch of inlining to find the calls to them.

Fixes rust-lang#138136

~~Draft as it's built atop rust-lang#138135, which adds a mir-opt test that's a nice demonstration of this.  To see just this change, look at <https://github.com/rust-lang/rust/pull/138157/commits/48f63e3be552605c2933056b77bf23a326757f92>~~ Rebased to be just the inlining change, as the other existing tests show it great.
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 13, 2025
…oli-obk

Allow more top-down inlining for single-BB callees

This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if
we've already done a bunch of inlining to find the calls to them.

Fixes rust-lang#138136

~~Draft as it's built atop rust-lang#138135, which adds a mir-opt test that's a nice demonstration of this.  To see just this change, look at <https://github.com/rust-lang/rust/pull/138157/commits/48f63e3be552605c2933056b77bf23a326757f92>~~ Rebased to be just the inlining change, as the other existing tests show it great.
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 13, 2025
…oli-obk

Allow more top-down inlining for single-BB callees

This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if
we've already done a bunch of inlining to find the calls to them.

Fixes rust-lang#138136

~~Draft as it's built atop rust-lang#138135, which adds a mir-opt test that's a nice demonstration of this.  To see just this change, look at <https://github.com/rust-lang/rust/pull/138157/commits/48f63e3be552605c2933056b77bf23a326757f92>~~ Rebased to be just the inlining change, as the other existing tests show it great.
@bors bors closed this as completed in 523c507 Mar 14, 2025
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this issue Mar 19, 2025
…oli-obk

Allow more top-down inlining for single-BB callees

This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if
we've already done a bunch of inlining to find the calls to them.

Fixes rust-lang#138136

~~Draft as it's built atop rust-lang#138135, which adds a mir-opt test that's a nice demonstration of this.  To see just this change, look at <https://github.com/rust-lang/rust/pull/138157/commits/48f63e3be552605c2933056b77bf23a326757f92>~~ Rebased to be just the inlining change, as the other existing tests show it great.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining needs-triage This issue may need triage. Remove it if it has been sufficiently triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants