Bug 21526 – x87 not rounding to precision on assignment on some platforms

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2021-01-05T09:45:28Z
Last change time
2021-01-08T09:32:45Z
Keywords
backend, pull, wrong-code
Assigned to
No Owner
Creator
Walter Bright

Comments

Comment #0 by bugzilla — 2021-01-05T09:45:28Z
For the code: float f(float a, float b) { float c = a + b; float d = c - b; return d; } When compiling with -m32 -O, on Windows c is stored to memory rounding it to float precision. This is correct. push EAX push EAX fld float ptr 010h[ESP] fadd float ptr 0Ch[ESP] fstp float ptr [ESP] // store fld float ptr [ESP] // reload fsub float ptr 0Ch[ESP] fstp float ptr 4[ESP] fld float ptr 4[ESP] add ESP,8 ret 8 On Linux, it does not, which is incorrect. fld float ptr 8[ESP] fadd float ptr 4[ESP] fsub float ptr 4[ESP] ret 8
Comment #1 by dlang-bot — 2021-01-06T10:55:08Z
@WalterBright created dlang/dmd pull request #12102 "fix Issue 21526 - x87 not rounding to precision on assignment on some…" fixing this issue: - fix Issue 21526 - x87 not rounding to precision on assignment on some platforms https://github.com/dlang/dmd/pull/12102
Comment #2 by ibuclaw — 2021-01-06T11:41:07Z
Comment #3 by dlang-bot — 2021-01-08T09:32:45Z
dlang/dmd pull request #12102 "fix Issue 21526 - x87 not rounding to precision on assignment on some…" was merged into master: - 455f606b7d6f4b220da14ae6432249f34a0e8cf6 by Walter Bright: fix Issue 21526 - x87 not rounding to precision on assignment on some platforms https://github.com/dlang/dmd/pull/12102