5885 – wrong codegen for OPu32_d

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5885 - wrong codegen for OPu32_d
Summary: wrong codegen for OPu32_d
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 All
: P2 critical
Assignee: No Owner
URL:
Keywords: patch, wrong-code
Depends on:
Blocks:
Reported: 2011年04月25日 07:32 UTC by Martin Nowak
Modified: 2011年06月28日 15:00 UTC (History)
2 users (show)

See Also:


Attachments
patch (1.21 KB, patch)
2011年04月25日 07:32 UTC, Martin Nowak
Details | Diff
new fix (1.12 KB, patch)
2011年05月21日 05:08 UTC, Martin Nowak
Details | Diff
Show Obsolete (1) Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Martin Nowak 2011年04月25日 07:32:40 UTC
Created attachment 948 [details] 
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.
Comment 1 Martin Nowak 2011年05月21日 05:08:47 UTC
Created attachment 988 [details] 
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.


AltStyle によって変換されたページ (->オリジナル) /