Missed optimization: big immutable locals are not promoted to constants #136218
Labels
A-codegen
Area: Code generation
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-optimization
Category: An issue highlighting optimization opportunities or PRs implementing such
I-slow
Issue: Problems and improvements with respect to performance of generated code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code, on
riscv32i-unknown-none-elf
(this code is originally from #136216):I expected to see this happen: compiler outputs identical asm for both functions.
Instead, this happened: the asm for
lookup_local
is suboptimal (godbolt):Instead of a using constant,
lookup_local
constructs the array on the stack.This might be a missed optimization in the LLVM, but we could also potentially handle it in rustc (and personally I feel like the latter might be easier).
Meta
rustc --version --verbose
:above is the code from godbolt, locally I get slightly different output
rustc +nightly ./t.rs --target riscv32i-unknown-none-elf -Copt-level=3 -Zexport-executable-symbols
,objdump --disassemble t
The text was updated successfully, but these errors were encountered: