Source file
test/simd.go
1
2
3
4
5
6
7
8
9 package foo
10
11 import "simd"
12
13 func f1(x simd.Int8x16) {
14 return
15 }
16
17 func g1() simd.Int8x16 {
18 var x simd.Int8x16
19 return x
20 }
21
22 type T1 simd.Int8x16
23
24 func (x T1) h() {
25 return
26 }
27
28 func f2(x simd.Int8x64) {
29 return
30 }
31
32 func g2() simd.Int8x64 {
33 var x simd.Int8x64
34 return x
35 }
36
37 type T2 simd.Int8x64
38
39 func (x T2) h() {
40 return
41 }
42
43 var a int
44
45 func f() {
46 if a == 0 {
47 if !simd.X86.AVX512() {
48 return
49 }
50 println("has avx512")
51 } else {
52 if !simd.X86.AVX2() {
53 return
54 }
55 println("has avx2")
56 }
57 println("has something")
58 }
59
60 func g() {
61 if simd.X86.AVX2() {
62 for range 5 {
63 if a < 0 {
64 a++
65 }
66 }
67 }
68 println("ahoy!")
69 if a > 0 {
70 a--
71 }
72 }
73
74
75 func p() bool {
76 return true
77 }
78
79 func hasIrreducibleLoop() {
80 if simd.X86.AVX2() {
81 goto a
82 } else {
83 goto b
84 }
85 a:
86 println("a")
87 if p() {
88 goto c
89 }
90 b:
91 println("b")
92 if p() {
93 goto a
94 }
95 c:
96 println("c")
97 }
98
99 func ternRewrite(m, w, x, y, z simd.Int32x16) (t0, t1, t2 simd.Int32x16) {
100 if !simd.X86.AVX512() {
101 return
102 }
103 t0 = w.Xor(y).Xor(z)
104 t1 = m.And(w.Xor(y).Xor(z.Not()))
105 t2 = x.Xor(y).Xor(z).And(x.Xor(y).Xor(z.Not()))
106 return
107 }
108
109 func ternTricky1(x, y, z simd.Int32x8) simd.Int32x8 {
110
111
112 a := x.Xor(y).Xor(z)
113 var w simd.Int32x8
114 if !simd.X86.AVX512() {
115
116 } else {
117 w = y.AndNot(a)
118 }
119
120 return a.Or(w)
121 }
122
123 func ternTricky2(x, y, z simd.Int32x8) simd.Int32x8 {
124
125 var a, w simd.Int32x8
126 if !simd.X86.AVX512() {
127
128 } else {
129 a = x.Xor(y).Xor(z)
130 w = y.AndNot(a)
131 }
132
133 return a.Or(w)
134 }
135
136 func ternTricky3(x, y, z simd.Int32x8) simd.Int32x8 {
137
138 a := x.Xor(y).Xor(z)
139 w := y.AndNot(a)
140 if !simd.X86.AVX512() {
141 return a
142 }
143
144 return a.Or(w)
145 }
146
View as plain text