Inlining leaves extra assembly #141144
Labels
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.
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
I have found a weird issue with inlining. I have expected these two functions to have the same assembly, but the second one has extra code:
Code to reproduce: godbolt.org (nightly,
-C opt-level=3
)Code
Considering different examples (
if
ormatch
), especially(cmp == Less)
, my guess is that the second usage of thecmp
variable duplicates the assembly offn compare
.Update
Example with generics (closure), not affected by
-C debuginfo=0
or-C opt-level=1
: godbolt.orgCode
Full project with this issue
Here even
#[inline(always)]
for the closure does not help: https://github.com/RoDmitry/alphabet_detector/tree/141144Path is
alphabet_detector/src/lang/ucd/script.rs
starting from line 453.Two identical functions, only difference is a generic
Fn
:cargo asm alphabet_detector::lang::ucd::script::UcdScript::find
Asm
cargo asm alphabet_detector::lang::ucd::script::UcdScript::find_broken
Asm
The text was updated successfully, but these errors were encountered: