Missed optimization when looping over bytes of a value #133528
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
llvm-fixed-upstream
Issue expected to be fixed by the next major LLVM upgrade, or backported fixes
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code, which contains 3 functions which check if all the bits in a u64 are all ones:
I expected to see this happen:
ne_bytes()
should be optimized to the same thing asdirect()
, whileblack_box_ne_bytes()
should be optimized slightly worseInstead, this happened: I got the following assembly, where
ne_bytes()
is somehow optimized worse thanblack_box_ne_bytes()
Godbolt
Meta
Reproducible on godbolt with stable
rustc 1.82.0 (f6e511eec 2024-10-15)
and nightlyrustc 1.85.0-nightly (7db7489f9 2024-11-25)
The text was updated successfully, but these errors were encountered: