-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Regression: Inlined loops not fully evaluating with const
-eable dependencies
#101082
Comments
const
-eable dependenciesconst
-eable dependencies
@rustbot label regression-from-stable-to-nightly |
@rustbot label I-slow |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-high t-compiler |
Partial fix: llvm/llvm-project@43e7d9a This at least allows the loop to be unrolled, though it only gets fully constant folded in the backend. |
Oh my, if it isn't yet another casualty of LLVM's dumb typed GEP representation. This might get fixed by #98615 as well. |
This turns out to be surprisingly tricky due to phase ordering issues. Even with canonical GEPs, the loop bounds only become known after full unrolling, by which point it is too late. I think the best shot at this would be to generalize LICM scalar promotion to perform load promotion in the presence of potentially aliasing loads. https://reviews.llvm.org/D133111 is preparation to move in that direction. |
https://reviews.llvm.org/D133192 for improved LICM promotion. Still needs to be combined with canonical GEPs to work. |
@nikic what are your thoughts on this ticket? Your partial fix was merged, but the other LLVM changes have not. Meanwhile, it seems like #98615 has stalled, but nikic r+'ed it apart from wanting a FIXME removed, does that sound right? (I went ahead and added a commit to remove the FIXME.) And its not clear whether #98615 would actually resolve this, is that correct? |
@pnkfelix We need both #98615 and https://reviews.llvm.org/D133192 to fully resolve this, as far as I remember. We should probably land #98615 ASAP to give us a chance to address regressions from it in LLVM 16. |
Fixed by the LLVM 16 upgrade. |
Fixes rust-lang#75978. Fixes rust-lang#99960. Fixes rust-lang#101048. Fixes rust-lang#101082. Fixes rust-lang#101814. Fixes rust-lang#103132. Fixes rust-lang#103327.
Add codegen tests for issues fixed by LLVM 16 Fixes rust-lang#75978. Fixes rust-lang#99960. Fixes rust-lang#101048. Fixes rust-lang#101082. Fixes rust-lang#101814. Fixes rust-lang#103132. Fixes rust-lang#103327.
Add codegen tests for issues fixed by LLVM 16 Fixes rust-lang#75978. Fixes rust-lang#99960. Fixes rust-lang#101048. Fixes rust-lang#101082. Fixes rust-lang#101814. Fixes rust-lang#103132. Fixes rust-lang#103327.
I tried this code:
I expected to see this happen: The loop should be inlined because
values
is const-known. For example, here is the generated assembly on Rust 1.63.0 (Godbolt) and Rust Beta (Godbolt):Instead, this happened: On nightly, the loop is inlined. However, the entire function is not computed despite the stable and beta Rust inlining it. Here is the generated assembly on Nightly (Godbolt):
Meta
n/a - disclosed at usages
Keywords: const inline loop, const loop, const loop not evaluated
Relevant discord thread: https://discord.com/channels/273534239310479360/592856094527848449/1013050670942793808
The text was updated successfully, but these errors were encountered: