Thread overview
[Issue 5885] New: wrong codegen for OPu32_d
Apr 25, 2011
dawg@dawgfoto.de
May 21, 2011
dawg@dawgfoto.de
Jun 28, 2011
Walter Bright
April 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5885

           Summary: wrong codegen for OPu32_d
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: dawg@dawgfoto.de


--- Comment #0 from dawg@dawgfoto.de 2011-04-25 07:32:40 PDT ---
Created an attachment (id=948)
patch

struct Value {
  uint a, b;
}

double mul(Value val, double fac) {
  return val.a * fac;
}

int main() {
  auto a = mul(Value(10), 10.0); // seems to work as val.b == 0
  auto b = mul(Value(10, 20), 10.0); // loads the 20 in the fpu
  return a == b ? 0 : 1;
}

--

What happens is that the complete rdi register gets pushed and a 64 bit integer is loaded from that address to the FPU. Maybe I'm missing something but loading an 32 bit simplifies even the 32-bit code. See attached patch.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5885


dawg@dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #948 is|0                           |1
           obsolete|                            |


--- Comment #1 from dawg@dawgfoto.de 2011-05-21 05:08:47 PDT ---
Created an attachment (id=988)
new fix

The proposed patch was wrong. FILD m64int needs to be used as there are no unsigned->fpu load instructions. The new patch explicitly zeros the upper 4 bytes.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 28, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5885


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2011-06-28 15:00:31 PDT ---
https://github.com/D-Programming-Language/dmd/commit/64a24b9276fd45c3040b5c726452a28add714cb7

https://github.com/D-Programming-Language/dmd/commit/bb40a40b6f804614ffc76ec79e10e7e1881b4c38

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------