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

Reference of literal is not optimized out #135469

Open
CrazyboyQCD opened this issue Jan 14, 2025 · 0 comments
Open

Reference of literal is not optimized out #135469

CrazyboyQCD opened this issue Jan 14, 2025 · 0 comments
Labels
C-optimization Category: An issue highlighting optimization opportunities or PRs implementing such T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@CrazyboyQCD
Copy link

https://godbolt.org/z/W1Gbnfjz9
Consider code like this, the codegen includes unnecessary reference of literal :

const T: [u8; 512] = ...;
pub fn f(a: usize) -> u8 {
    *T.get(a).unwrap_or(&1)
}
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 14, 2025
@lolbinarycat lolbinarycat added C-optimization Category: An issue highlighting optimization opportunities or PRs implementing such T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 14, 2025
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-optimization Category: An issue highlighting optimization opportunities or PRs implementing such T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants