Source file
src/simd/archsimd/ops_emulated_amd64.go
1
2
3
4
5
6
7 package archsimd
8
9
10
11
12 func (x Float32x4) Abs() Float32x4 {
13 mask := BroadcastUint32x4(0x80000000)
14 return x.ToBits().AndNot(mask).BitsToFloat32()
15 }
16
17
18
19
20 func (x Float32x8) Abs() Float32x8 {
21
22 mask := BroadcastUint32x8(0x80000000)
23 return x.ToBits().AndNot(mask).BitsToFloat32()
24 }
25
26
27
28
29 func (x Float32x16) Abs() Float32x16 {
30 mask := BroadcastUint32x16(0x80000000)
31 return x.ToBits().AndNot(mask).BitsToFloat32()
32 }
33
34
35
36
37 func (x Float64x2) Abs() Float64x2 {
38
39 mask := BroadcastUint64x2(0x8000000000000000)
40 return x.ToBits().AndNot(mask).BitsToFloat64()
41 }
42
43
44
45
46 func (x Float64x4) Abs() Float64x4 {
47 mask := BroadcastUint64x4(0x8000000000000000)
48 return x.ToBits().AndNot(mask).BitsToFloat64()
49 }
50
51
52
53
54 func (x Float64x8) Abs() Float64x8 {
55 mask := BroadcastUint64x8(0x8000000000000000)
56 return x.ToBits().AndNot(mask).BitsToFloat64()
57 }
58
59
60
61
62 func (x Float32x4) Neg() Float32x4 {
63 mask := BroadcastUint32x4(0x80000000)
64 return x.ToBits().Xor(mask).BitsToFloat32()
65 }
66
67
68
69
70 func (x Float32x8) Neg() Float32x8 {
71
72 mask := BroadcastUint32x8(0x80000000)
73 return x.ToBits().Xor(mask).BitsToFloat32()
74 }
75
76
77
78
79 func (x Float32x16) Neg() Float32x16 {
80 mask := BroadcastUint32x16(0x80000000)
81 return x.ToBits().Xor(mask).BitsToFloat32()
82 }
83
84
85
86
87 func (x Float64x2) Neg() Float64x2 {
88
89 mask := BroadcastUint64x2(0x8000000000000000)
90 return x.ToBits().Xor(mask).BitsToFloat64()
91 }
92
93
94
95
96 func (x Float64x4) Neg() Float64x4 {
97 mask := BroadcastUint64x4(0x8000000000000000)
98 return x.ToBits().Xor(mask).BitsToFloat64()
99 }
100
101
102
103
104 func (x Float64x8) Neg() Float64x8 {
105 mask := BroadcastUint64x8(0x8000000000000000)
106 return x.ToBits().Xor(mask).BitsToFloat64()
107 }
108
109 var f0x16 = [16]int8{-1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0}
110 var f0x32 = [32]int8{-1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0,
111 -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0}
112 var f0x64 = [64]int8{-1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0,
113 -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0,
114 -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0,
115 -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0}
116
117
118
119
120 func (x Int8x16) Mul(y Int8x16) Int8x16 {
121 mask := LoadInt8x16Array(&f0x16)
122 mask16 := mask.ToBits().ReshapeToUint16s()
123 xe := x.And(mask).ToBits().ReshapeToUint16s()
124 xo := x.AndNot(mask).ToBits().ReshapeToUint16s().ShiftAllRight(8)
125 ye := y.And(mask).ToBits().ReshapeToUint16s()
126 yo := y.AndNot(mask).ToBits().ReshapeToUint16s().ShiftAllRight(8)
127 pe := xe.Mul(ye).And(mask16)
128 po := xo.Mul(yo).And(mask16).ShiftAllLeft(8)
129 return pe.Or(po).ReshapeToUint8s().BitsToInt8()
130 }
131
132
133
134
135 func (x Uint8x16) Mul(y Uint8x16) Uint8x16 {
136 mask := LoadInt8x16Array(&f0x16).ToBits()
137 mask16 := mask.ReshapeToUint16s()
138 xe := x.And(mask).ReshapeToUint16s()
139 xo := x.AndNot(mask).ReshapeToUint16s().ShiftAllRight(8)
140 ye := y.And(mask).ReshapeToUint16s()
141 yo := y.AndNot(mask).ReshapeToUint16s().ShiftAllRight(8)
142 pe := xe.Mul(ye).And(mask16)
143 po := xo.Mul(yo).And(mask16).ShiftAllLeft(8)
144 return pe.Or(po).ReshapeToUint8s()
145 }
146
147
148
149
150 func (x Int8x32) Mul(y Int8x32) Int8x32 {
151 mask := LoadInt8x32Array(&f0x32)
152 mask16 := mask.ToBits().ReshapeToUint16s()
153 xe := x.And(mask).ToBits().ReshapeToUint16s()
154 xo := x.AndNot(mask).ToBits().ReshapeToUint16s().ShiftAllRight(8)
155 ye := y.And(mask).ToBits().ReshapeToUint16s()
156 yo := y.AndNot(mask).ToBits().ReshapeToUint16s().ShiftAllRight(8)
157 pe := xe.Mul(ye).And(mask16)
158 po := xo.Mul(yo).And(mask16).ShiftAllLeft(8)
159 return pe.Or(po).ReshapeToUint8s().BitsToInt8()
160 }
161
162
163
164
165 func (x Int8x64) Mul(y Int8x64) Int8x64 {
166 mask := LoadInt8x64Array(&f0x64)
167 mask16 := mask.ToBits().ReshapeToUint16s()
168 xe := x.And(mask).ToBits().ReshapeToUint16s()
169 xo := x.AndNot(mask).ToBits().ReshapeToUint16s().ShiftAllRight(8)
170 ye := y.And(mask).ToBits().ReshapeToUint16s()
171 yo := y.AndNot(mask).ToBits().ReshapeToUint16s().ShiftAllRight(8)
172 pe := xe.Mul(ye).And(mask16)
173 po := xo.Mul(yo).And(mask16).ShiftAllLeft(8)
174 return pe.Or(po).ReshapeToUint8s().BitsToInt8()
175 }
176
177
178
179
180 func (x Uint8x32) Mul(y Uint8x32) Uint8x32 {
181 mask := LoadInt8x32Array(&f0x32).ToBits()
182 mask16 := mask.ReshapeToUint16s()
183 xe := x.And(mask).ReshapeToUint16s()
184 xo := x.AndNot(mask).ReshapeToUint16s().ShiftAllRight(8)
185 ye := y.And(mask).ReshapeToUint16s()
186 yo := y.AndNot(mask).ReshapeToUint16s().ShiftAllRight(8)
187 pe := xe.Mul(ye).And(mask16)
188 po := xo.Mul(yo).And(mask16).ShiftAllLeft(8)
189 return pe.Or(po).ReshapeToUint8s()
190 }
191
192
193
194
195 func (x Uint8x64) Mul(y Uint8x64) Uint8x64 {
196 mask := LoadInt8x64Array(&f0x64).ToBits()
197 mask16 := mask.ReshapeToUint16s()
198 xe := x.And(mask).ReshapeToUint16s()
199 xo := x.AndNot(mask).ReshapeToUint16s().ShiftAllRight(8)
200 ye := y.And(mask).ReshapeToUint16s()
201 yo := y.AndNot(mask).ReshapeToUint16s().ShiftAllRight(8)
202 pe := xe.Mul(ye).And(mask16)
203 po := xo.Mul(yo).And(mask16).ShiftAllLeft(8)
204 return pe.Or(po).ReshapeToUint8s()
205 }
206
View as plain text