Missed optimization with reserve and extend_from_slice #123944
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
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen: only one
do_reserve_and_handle
call.Instead, this happened:
extend_from_slice
stills checks the capacity and calls reserve. It seems like LLVM assumes aren't able to bubble up out of multiple functions. I was able to get the optimization to work in #119465 but it required putting assumes in every function along the reserve chain.The text was updated successfully, but these errors were encountered: