Issue 9304 - Unary minus operator doesn't work correctly with SIMD types.
Summary: Unary minus operator doesn't work correctly with SIMD types.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-12 11:01 UTC by jerro.public
Modified: 2013-01-15 13:51 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description jerro.public 2013-01-12 11:01:38 UTC
The following code does not work correctly when compiled with DMD 2.061 with -O flag:

import std.stdio;
import core.simd;

// alias float4 T; // internal compiler error
alias int4 T;  // wrong result

T foo(T a)
{
    return -a;
}

void main()
{
    auto a = foo([0, 1, 2, 3]);
    writeln(a.array);
}

If T is float4, I get internal compiler error:

Internal error: ../ztc/cgxmm.c 57

If T is int4, the code compiles, but prints this when I run it (the first number is different each time, the other three stay the same):

[-1111986510, 32712, 0, 0]

If I don't use -O flag, the code compiles and works correctly for both int4 and float4.
Comment 1 github-bugzilla 2013-01-15 03:07:27 UTC
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/ecb14d78cdd04813382676e9ff10e3c43c5bdb63
fix Issue 9304 - Unary minus operator doesn't work correctly with SIMD types.
Comment 3 github-bugzilla 2013-01-15 13:49:52 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/d6eaab75bead8f17e4b045add7c4b5bd1bc91365
fix Issue 9304 - Unary minus operator doesn't work correctly with SIMD types.

https://github.com/D-Programming-Language/dmd/commit/065f9861652a510c9afc0747c3f066927934e1e9
Merge pull request #1488 from WalterBright/b10

fix Issue 9304 - Unary minus operator doesn't work correctly with SIMD t...