Bug 8060 – xmmstore cannot allocate store for optimized operation that uses int and floats
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2012-05-07T13:51:00Z
Last change time
2015-06-09T05:11:51Z
Assigned to
nobody
Creator
fawzi
Comments
Comment #0 by fawzi — 2012-05-07T13:51:45Z
float invSqrt(float x) {
union fi {
float f;
int i;
}
fi v;
float xhalf = 0.5f * x;
v.f = x;
v.i = 0x5f375a86 - (v.i >> 1);
float y = x * v.f;
float z = y*(1.5f - xhalf * y * y);
return z;
}
or
float invSqrt(float x) {
float xhalf = 0.5f * x;
int i = *cast(int*)&x;
i = 0x5f375a86 - (i >> 1);
x = *cast(float*)&i;
x = x*(1.5f - xhalf * x * x);
return x;
}
fails with error
tym = xa
Internal error: ../ztc/cgxmm.c 567
when compiled with dmd 1.074 or 2.059 with -O
Comment #1 by fawzi — 2012-05-07T13:54:15Z
well probably the optimizer should not expect such a thing to be possible.
Comment #2 by clugdbug — 2012-05-14T00:59:21Z
Reduced test case. The float needs to be a parameter (not a local variable).
float bug8060(float x) {
int i = *cast(int*)&x;
++i;
return *cast(float*)&i;
}
Comment #3 by github-bugzilla — 2012-05-18T23:02:52Z