1
2
3
4
5
6
7
8
9
10
11 package codegen
12
13 import "simd"
14
15 func vptest1() bool {
16 v1 := simd.LoadUint64x2Slice([]uint64{0, 1})
17 v2 := simd.LoadUint64x2Slice([]uint64{0, 0})
18
19
20 return v1.AndNot(v2).IsZero()
21 }
22
23 func vptest2() bool {
24 v1 := simd.LoadUint64x2Slice([]uint64{0, 1})
25 v2 := simd.LoadUint64x2Slice([]uint64{0, 0})
26
27
28 return v1.And(v2).IsZero()
29 }
30
31 type Args2 struct {
32 V0 simd.Uint8x32
33 V1 simd.Uint8x32
34 x string
35 }
36
37
38 func simdStructNoSpill(a Args2) simd.Uint8x32 {
39
40 return a.V0.Xor(a.V1)
41 }
42
43 func simdStructWrapperNoSpill(a Args2) simd.Uint8x32 {
44
45 a.x = "test"
46 return simdStructNoSpill(a)
47 }
48
49
50 func simdArrayNoSpill(a [1]Args2) simd.Uint8x32 {
51
52 return a[0].V0.Xor(a[0].V1)
53 }
54
55 func simdArrayWrapperNoSpill(a [1]Args2) simd.Uint8x32 {
56
57 a[0].x = "test"
58 return simdArrayNoSpill(a)
59 }
60
61 func simdFeatureGuardedMaskOpt() simd.Int16x16 {
62 var x, y simd.Int16x16
63 if simd.X86.AVX512() {
64 mask := simd.Mask16x16FromBits(5)
65 return x.Add(y).Masked(mask)
66 }
67 mask := simd.Mask16x16FromBits(5)
68 return x.Add(y).Masked(mask)
69 }
70
71 func simdMaskedMerge() simd.Int16x16 {
72 var x, y simd.Int16x16
73 if simd.X86.AVX512() {
74 mask := simd.Mask16x16FromBits(5)
75 return x.Add(y).Merge(x, mask)
76 }
77 mask := simd.Mask16x16FromBits(5)
78 return x.Add(y).Merge(x, mask)
79 }
80
View as plain text