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

Compiler generates suboptimal code when array is iterated (works fine with slice). #94917

Closed
VorfeedCanal opened this issue Mar 13, 2022 · 3 comments
Assignees
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-slow Issue: Problems and improvements with respect to performance of generated code.

Comments

@VorfeedCanal
Copy link

Couldn't find if that was reported yet.

This is example from reddit:

This produces suboptimal results:

    for name in name_arr {
        print!("{}", name.get_name());
    }

while this works as expected:

    for name in &name_arr {
        print!("{}", name.get_name());
    }

Godbolt reference with comparison: https://godbolt.org/z/1T6G3s7Gz

@nikic nikic added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-slow Issue: Problems and improvements with respect to performance of generated code. labels Mar 13, 2022
@nikic nikic self-assigned this Dec 21, 2022
@nikic
Copy link
Contributor

nikic commented Dec 21, 2022

Should be fixed in LLVM 16, assigning to track.

@nikic nikic added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 3, 2023
@nikic
Copy link
Contributor

nikic commented Apr 3, 2023

Fixed by the LLVM 16 upgrade.

@nikic
Copy link
Contributor

nikic commented Apr 3, 2023

Not going to add a separate test for this, I think this is effectively covered by #101082.

@nikic nikic closed this as completed Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-slow Issue: Problems and improvements with respect to performance of generated code.
Projects
None yet
Development

No branches or pull requests

2 participants