Bug 20363 – painting XMM registers as integers leads to codegen bugs

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-11-06T16:43:44Z
Last change time
2021-02-15T11:01:02Z
Keywords
pull, wrong-code
Assigned to
No Owner
Creator
berni44
Blocks
18750

Comments

Comment #0 by bugzilla — 2019-11-06T16:43:44Z
auto test(double val) { union A { double a; ulong b; } A fb; fb.a = val; auto sgn = ((fb.b >> 63) & 1) ? "-" : "+"; import std.stdio; writeln(sgn); } void main() { test(-double.nan); } When running this with "rdmd -O" I get "+" not the expected "-". Without the -O flag it works.
Comment #1 by ag0aep6g — 2019-11-07T01:01:27Z
Seems to be (yet another) bug related to the `bt` instruction. Smaller test case: ---- ulong test(double d) { ulong u = * cast(ulong*) &d; return (u >> 1) & 1; } void main() { ulong u = 0b10; if (test(* cast(double*) &u) == 0) assert(false); /* fails with -O */ } ---- The generated code for `test`: ---- 0: 48 0f ba e0 01 bt rax,0x1 5: 19 c0 sbb eax,eax 7: f7 d8 neg eax 9: c3 ret ---- It misses code that fills `rax`.
Comment #2 by dlang-bot — 2020-06-10T09:12:19Z
@WalterBright created dlang/dmd pull request #11257 "fix Issue 20363 - painting XMM registers as integers leads to codegen…" fixing this issue: - fix Issue 20363 - painting XMM registers as integers leads to codegen bugs https://github.com/dlang/dmd/pull/11257
Comment #3 by dlang-bot — 2020-07-02T16:25:44Z
dlang/dmd pull request #11257 "fix Issue 20363 - painting XMM registers as integers leads to codegen…" was merged into master: - 1f6cde0c00fbcd62b363416939bb23be647e38a8 by Walter Bright: fix Issue 20363 - painting XMM registers as integers leads to codegen bugs https://github.com/dlang/dmd/pull/11257
Comment #4 by dlang-bot — 2021-02-15T11:01:02Z
dlang/phobos pull request #7757 "Partial replace call to snprintf for formating floatingpoint numbers for %f and %F" was merged into master: - 2fc1abc961e28c01fd35e220dfd782b606f9f11e by berni44: Some small corrections Bug 20363 (which has acidentially been written as 20636) has meanwhile been taken care of, so no hack needed anymore Remove two missleading comments (there is no more cast needed) Adapt new convention for naming bug reports Add missing spaces arround operators https://github.com/dlang/phobos/pull/7757