Performance regression on toy problem, but not for opt-level=1. #135241
Labels
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.
P-low
Low priority
regression-untriaged
Untriaged performance or correctness regression.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
I expected compiling with
rustc -C opt-level=3
to be faster thanrustc -C opt-level=1
. I have not seen any resources online giving a recommendation foropt-level=1
or any downside to more optimization other than binary size.However, only with
opt-level=1
does rustc figure out thatstart
,end
, andaux
are useless and combine the two recursive calls. Combining the two recursive calls results in linear time complexity vs exponential so it is immediately noticeable even without any tight timing (> minutes vs milliseconds).Previous versions correctly compile this toy code into non-exponential machine code. It seems to have broken around 1.70 and is currently broken on both stable and nightly.
I am totally willing to investigate this, but I would need some guidance because I have never looked deeply into LLVM's or Rust's optimization passes.
Version it worked on
It most recently worked on
rustc --version --verbose
:Version with regression
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: