Skip to content

Add frexpf128, ilogbf16, and ilogbf128#862

Merged
tgross35 merged 2 commits intorust-lang:mainfrom
tgross35:generic-frexp-ilogb
Feb 12, 2026
Merged

Add frexpf128, ilogbf16, and ilogbf128#862
tgross35 merged 2 commits intorust-lang:mainfrom
tgross35:generic-frexp-ilogb

Conversation

@tgross35
Copy link
Contributor

@tgross35 tgross35 commented Apr 20, 2025

ci: allow-regressions

@tgross35 tgross35 force-pushed the generic-frexp-ilogb branch 10 times, most recently from 0c317ce to 08d2f0b Compare February 12, 2026 02:25
@tgross35 tgross35 changed the title Add frexpf16, frexpf128, ilogbf16, and ilogbf128 Add frexpf128, ilogbf16, and ilogbf128 Feb 12, 2026
@tgross35 tgross35 force-pushed the generic-frexp-ilogb branch 6 times, most recently from 9d13db3 to d2d2ba4 Compare February 12, 2026 03:19
@tgross35 tgross35 marked this pull request as ready for review February 12, 2026 03:20
@tgross35
Copy link
Contributor Author

Current regression on aarch64 shows

  icount::icount_bench_frexp_group::icount_bench_frexp logspace:
    Callgrind: Instructions (7719 -> 8219): +6.47752% exceeds limit of +5.00000%
  icount::icount_bench_frexpf_group::icount_bench_frexpf logspace:
    Callgrind: Instructions (7751 -> 8251): +6.45078% exceeds limit of +5.00000%

Previously there was a single function, but with the generic there is:

$ cargo asm -p libm --lib --target aarch64-unknown-linux-gnu frexp 0
   Compiling libm v0.2.16 (~/projects/compiler-builtins/libm)
    Finished `release` profile [optimized] target(s) in 1.11s

.section .text.libm::math::frexp::frexp,"ax",@progbits
        .globl  libm::math::frexp::frexp
        .p2align        2
.type   libm::math::frexp::frexp,@function
libm::math::frexp::frexp:
        .cfi_startproc
        b libm::math::generic::frexp::frexp::<f64>

Not sure why it isn't getting inlined, even #[inline(always)] doesn't help.

The `frexpf16` signature is added (to make traits easier) but left
unimplemented, since it will need a slightly different algorithm.
@tgross35 tgross35 force-pushed the generic-frexp-ilogb branch from d2d2ba4 to 4accc08 Compare February 12, 2026 03:43
@tgross35
Copy link
Contributor Author

Oh, duh, it won't inline because the generic frexp calls itself. x86 has the regression too, just not over the threshold:

icount::icount_bench_frexp_group::icount_bench_frexp logspace:setup_frexp()
  Baselines:                      softfloat|softfloat (old)
  Instructions:                       11689|11189                (+4.46867%) [+1.04469x]
  L1 Hits:                            13274|12777                (+3.88980%) [+1.03890x]
  LL Hits:                                3|1                    (+200.000%) [+3.00000x]
  RAM Hits:                               6|5                    (+20.0000%) [+1.20000x]
  Total read+write:                   13283|12783                (+3.91144%) [+1.03911x]
  Estimated Cycles:                   13499|12957                (+4.18307%) [+1.04183x]
icount::icount_bench_frexpf_group::icount_bench_frexpf logspace:setup_frexpf()
  Baselines:                      softfloat|softfloat (old)
  Instructions:                       10726|10226                (+4.88950%) [+1.04889x]
  L1 Hits:                            12321|11824                (+4.20332%) [+1.04203x]
  LL Hits:                                2|1                    (+100.000%) [+2.00000x]
  RAM Hits:                               5|5                    (No change)
  Total read+write:                   12328|11830                (+4.20964%) [+1.04210x]
  Estimated Cycles:                   12506|12004                (+4.18194%) [+1.04182x]

I'm just going to accept the regression here since I'll be following up with a change to the algorithm to support f16.

@tgross35 tgross35 merged commit 281c3b9 into rust-lang:main Feb 12, 2026
38 checks passed
@tgross35 tgross35 deleted the generic-frexp-ilogb branch February 12, 2026 04:56
@tgross35
Copy link
Contributor Author

#1092

@tgross35 tgross35 mentioned this pull request Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant