Skip to content

Commit e00a790

Browse files
[PARKED] FASTFLOAT_ASSUME_ROUNDS_TO_NEAREST: compile-time bypass of the rounds_to_nearest() probe
Opt-in macro folding rounds_to_nearest() to true, eliding the volatile-FCMP probe on the Clinger fast path (parity with ffc's FFC_ROUNDS_TO_NEAREST / EXP-030). Correctness: bit-identical to default over 200k values in round-to-nearest env (default build #ifdef-guarded => unchanged). Benchmark (4 Intel gens, c++17+20): marginal — mesh ~+2.6%, canada ~+1.5%, random neutral/noisy (random uses Eisel-Lemire, not the Clinger fast path, so no probe to elide). Per-cell noise incl. small regressions. PARKED: real but below the clean accept bar. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e0b53ea commit e00a790

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

include/fast_float/parse_number.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ from_chars_result_t<UC>
7676
* Credit : @mwalcott3
7777
*/
7878
fastfloat_really_inline bool rounds_to_nearest() noexcept {
79+
#ifdef FASTFLOAT_ASSUME_ROUNDS_TO_NEAREST
80+
// The caller asserts at compile time that the floating-point environment uses
81+
// the default IEEE-754 round-to-nearest mode (i.e. nothing ever changes the
82+
// rounding mode via fesetround()). This elides the volatile-float FCMP probe
83+
// below, removing it from the Clinger fast path.
84+
return true;
85+
#endif
7986
// https://lemire.me/blog/2020/06/26/gcc-not-nearest/
8087
#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
8188
return false;

0 commit comments

Comments
 (0)