Bug 19599 – Wrong codegen DMD x86_64 with both -O and -inline + double

Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2019-01-21T01:38:35Z
Last change time
2020-12-28T09:28:05Z
Keywords
backend, SIMD
Assigned to
No Owner
Creator
ponce

Comments

Comment #0 by aliloko — 2019-01-21T01:38:35Z
DMD v2.081.2 Build this with: dmd repro.d -m64 -inline -O --------- repro.d ----------- struct double2 { double[2] array; this(double[2] v) pure nothrow @safe @nogc { array[] = v[]; } ref inout(double) opIndex(size_t i) inout pure nothrow @safe @nogc { return array[i]; } } double2 _mm_sub_sd(double2 a, double2 b) pure @safe { a[0] -= b[0]; return a; } void main() { double2 a = [1.0, -2.0]; a = _mm_sub_sd(a, a); assert(a.array == [0.0, -2.0]); } ``` The assert doesn't pass. Instead a is equal to [1.0, -2.0]. It should be exactly [0.0, -2.0]
Comment #1 by aliloko — 2019-01-21T01:39:59Z
Also in dmd.2.084.0 + windows
Comment #2 by aliloko — 2020-12-11T05:00:26Z
Cannot reproduce in v2.094.0, was probabyl fixed at one point?
Comment #3 by bugzilla — 2020-12-28T09:28:05Z
Can confirm it is working now in master. (Don't know what change fixed it.) If you find some other variation on this that does not work, please file another bug report.