Skip to content

Keep the rounded primitives from being merged across rounding-mode changes - #65

Merged
Lastique merged 5 commits into
boostorg:developfrom
reach2sayan:fix/rounding-barrier-v2
Oct 29, 2026
Merged

Lastique merged 5 commits into
boostorg:developfrom
reach2sayan:fix/rounding-barrier-v2

Conversation

@reach2sayan

@reach2sayan reach2sayan commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

This continues #61, by @SonnyChecksIn. In his review there, @Lastique pointed out that the merge GCC did on sqrt "can happen with any operation, not just the square root. And on any target, not just x86".

#61 fixed sqrt; this PR does the same for the rest of the rounded primitives, using detail::reload_operand introduced in #61

The problem

An interval function calls the _down and _up primitives on the same operands, with a rounding-mode change in between. The compiler does not treat the mode change as a dependency, so it can compute x + y once and use it for both ends. The interval is then too narrow and can miss the true value.

test/rounding_merge.cpp (new) checks add, sub, mul, div, int and conv for float, double and long double, under rounded_arith_std and rounded_arith_opp.
On develop, with -frounding-math:

Compiler Merged on develop
g++ 13, x86-64, -O2/-O3 std + - * / (all types), std conv
g++ 13, -m32, -O2/-O3 also std int, and opp (default policy) long double + - * /
clang 18, x86-64, -O2/-O3 std long double + - * /
clang 18, -m32, -O2/-O3 also std int
clang 12, s390x, -O2/-O3 opp int_up returns the floor
any, -O0 none

Changes

  • rounded_arith_std: + - * /, conv and int read one operand through detail::reload_operand, as sqrt already does after Stop g++ merging the two square roots of a point interval #61. int_down and int_up also go through force_rounding, like every other primitive.
  • x87 long double (GCC and compatibles): force_rounding was an identity, so nothing kept the result before the next mode change. It is now an empty asm volatile with a "+t" operand and a "memory" clobber.
  • test/sqrt_rounding.cpp passes the same operand to both roots, so it also catches a merge. It now runs long double everywhere except IBM double-double, which ignores the rounding mode.

CI

The multiarch setup step no longer installs qemu-user-static. On ubuntu-latest, now Ubuntu 26.04, it is a virtual package and apt fails, so the four QEMU jobs could not start. The host package was never used anyway. It registers binfmt_misc handlers that point at the host's QEMU binaries, but the next step, bdde-multiarch, runs tonistiigi/binfmt --uninstall "qemu-*", which removes them, and then --install all, which registers the QEMU binaries from that image instead.

@reach2sayan
reach2sayan marked this pull request as draft October 26, 2026 12:12
@reach2sayan
reach2sayan marked this pull request as ready for review October 26, 2026 12:17
@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.79%. Comparing base (27a6fdf) to head (a4d2a46).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #65      +/-   ##
===========================================
+ Coverage    82.60%   82.79%   +0.18%     
===========================================
  Files           23       23              
  Lines         1006     1017      +11     
  Branches       410      412       +2     
===========================================
+ Hits           831      842      +11     
  Misses         167      167              
  Partials         8        8              
Files with missing lines Coverage Δ
...t/numeric/interval/detail/x86_rounding_control.hpp 100.00% <100.00%> (ø)
...umeric/interval/detail/x86gcc_rounding_control.hpp 100.00% <100.00%> (ø)
include/boost/numeric/interval/rounded_arith.hpp 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 27a6fdf...a4d2a46. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Lastique
Lastique merged commit 5d49468 into boostorg:develop Oct 29, 2026
63 checks passed
@reach2sayan
reach2sayan deleted the fix/rounding-barrier-v2 branch October 30, 2026 01:21
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.

2 participants