about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/errors.rs
diff options
context:
space:
mode:
authorMikhail Zabaluev <mikhail.zabaluev@gmail.com>2024-07-12 00:54:26 +0300
committerMikhail Zabaluev <mikhail.zabaluev@gmail.com>2024-07-12 00:54:26 +0300
commit1faa1018c7ddd2f505904b0f71255afa5ae1bbe7 (patch)
treeb847353e49e81d03154547fdd48478a29764025d /compiler/rustc_codegen_llvm/src/errors.rs
parentdf27dfa0eae8a14d69e5006334bb06d84ba050b7 (diff)
downloadrust-1faa1018c7ddd2f505904b0f71255afa5ae1bbe7.tar.gz
rust-1faa1018c7ddd2f505904b0f71255afa5ae1bbe7.zip
Explicitly unroll integer pow for small exponents
The newly optimized loop has introduced a regression in the case
when pow is called with a small constant exponent. LLVM is no longer
able to unroll the loop and the generated code is larger and slower
than what's expected in tests.

Match and handle small exponent values separately by branching out
to an explicit multiplication sequence for that exponent.
Powers larger than 6 need more than three multiplications, so these
cases are less likely to benefit from this optimization, also such
constant exponents are less likely to be used in practice.
For uses with a non-constant exponent, this might also provide
a performance benefit if the exponent is small and does not vary
between successive calls, so the same match arm tends to be taken as
a predicted branch.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
0 files changed, 0 insertions, 0 deletions