D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8060 - xmmstore cannot allocate store for optimized operation that uses int and floats
Summary: xmmstore cannot allocate store for optimized operation that uses int and floats
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P2 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-07 13:51 UTC by Fawzi Mohamed
Modified: 2015-06-09 05:11 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Fawzi Mohamed 2012-05-07 13:51:45 UTC
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 Fawzi Mohamed 2012-05-07 13:54:15 UTC
well probably the optimizer should not expect such a thing to be possible.
Comment 2 Don 2012-05-14 00:59:21 UTC
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 github-bugzilla 2012-05-18 23:02:52 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/70a0d0398810d7da989f778a2b4a3ab1037061dd
fix Issue 8060 - xmmstore cannot allocate store for optimized operation that uses int and floats
Comment 4 github-bugzilla 2012-05-18 23:03:08 UTC
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/cb946cd258a186f09cbaa303d1ded96a8ebb095d
fix Issue 8060 - xmmstore cannot allocate store for optimized operation that uses int and floats