blob: bed639c20255d6eba04384005029192c969d57c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
using System.Runtime.Intrinsics;
namespace GitHub_17435
{
class Program
{
const int Pass = 100;
const int Fail = 0;
static unsafe int Main(string[] args)
{
if (Sse2.IsSupported)
{
(uint a, uint b) = Program.Repro();
if ((a !=3) || (b != 6))
{
Console.WriteLine($"FAILED {a}, {b}");
return Fail;
}
else
{
Console.WriteLine("Passed");
return Pass;
}
}
else
{
Console.WriteLine("SSE2 not supported");
return Pass;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
public unsafe static (uint, uint) Repro()
{
uint* a = stackalloc uint[4];
a[0] = 1;
a[1] = 1;
a[2] = 1;
a[3] = 1;
// Here we force populate the registers
var b = a[0];
var h = a[3];
var c = a[1];
// We operate the values in xmm0
Vector128<uint> v = Sse2.LoadVector128(a);
v = Sse2.Add(v, v);
// We send to the memory the modified values
Sse2.Store(a, v);
// We return both sums (from registers and from memory)
return (b + h + c, a[0]+a[1]+a[3]);
}
}
}
|