[Issue 20363] optimization with union, >> and ulong leads to wrong result

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 7 01:01:27 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=20363

ag0aep6g <ag0aep6g at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |ag0aep6g at gmail.com
             Blocks|                            |18750

--- Comment #1 from ag0aep6g <ag0aep6g at gmail.com> ---
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`.


Referenced Issues:

https://issues.dlang.org/show_bug.cgi?id=18750
[Issue 18750] [Tracker] everything wrong with code generation for bt
instruction
--


More information about the Digitalmars-d-bugs mailing list