Created attachment 1666
Code that triggers bug
Result of function changes if DMD optimization is enabled.
$ dmd --version
DMD64 D Compiler v2.077.1
Copyright (c) 1999-2017 by Digital Mars written by Walter Bright
$ dmd test.d; ./test
11
true
$ dmd -O test.d; ./test
0
false
Comment #1 by bitter.taste — 2018-02-19T17:20:34Z
The problem is quite subtle, after the glocal pass the following code
```
ushort8 v=ushort8(check);
ubyte16 ok=__simd(XMM.PCMPEQW, control, v);
```
is turned into
```
ubyte16 ok=__simd(XMM.PCMPEQW, control, (ushort8 v = ushort8(check));
```
and since `v' isn't used anywhere else in the code the rmdeadass pass removes the dead assignment by turning the expression into
```
ubyte16 ok=__simd(XMM.PCMPEQW, control, (<bogus>, void16(check)));
```
Now, the ushort8 -> void16 conversion happens because that's the type of the third argument of the __simd function and, as a result, the vector is initialized with the wrong elements, leading to the failure reported above.
Comment #2 by github-bugzilla — 2018-04-16T00:31:47Z