Suboptimal codegen for a function that should fold to a constant
Open
@deniskilseev is already working on this.
Since Sep 29, 2024.
A-codegen
A-LLVM
C-optimization
I-slow
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I'm not entirely sure whether this belongs to LLVM or rust (I haven't triaged), but let's start here.
I tried this code: https://godbolt.org/z/E5W74re7v
which could potentially folded to a single constant, but the optimizer fails to recognize.
Changing the inner if condition from t + s + r == 10 to t + s == 10 results into the LLVM IR being a single line function:
ret i64 63000000000. In godbolt: https://godbolt.org/z/zfchrszbW
I would expect both cases to fold to a constant, but maybe I'm missing something here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.