Source file
src/simd/archsimd/maskrange_128.go
1
2
3
4
5
6
7 package archsimd
8
9 import "math/bits"
10
11
12
13
14 func (x Mask8x16) All() bool {
15 word := x.ToInt8x16().ToBits().ReshapeToUint64s()
16 a0 := word.GetElem(0)
17 b0 := word.GetElem(1)
18 return (a0&b0)&0x0101010101010101 == 0x0101010101010101
19 }
20
21
22
23
24 func (x Mask8x16) Any() bool {
25 word := x.ToInt8x16().ToBits().ReshapeToUint64s()
26 a0 := word.GetElem(0)
27 b0 := word.GetElem(1)
28 return (a0|b0)&0x0101010101010101 != 0
29 }
30
31
32
33
34 func (x Mask8x16) None() bool {
35 word := x.ToInt8x16().ToBits().ReshapeToUint64s()
36 a0 := word.GetElem(0)
37 b0 := word.GetElem(1)
38 return (a0|b0)&0x0101010101010101 == 0
39 }
40
41
42
43
44 func (x Mask16x8) All() bool {
45 word := x.ToInt16x8().ToBits().ReshapeToUint64s()
46 a0 := word.GetElem(0)
47 b0 := word.GetElem(1)
48 return (a0&b0)&0x0001000100010001 == 0x0001000100010001
49 }
50
51
52
53
54 func (x Mask16x8) Any() bool {
55 word := x.ToInt16x8().ToBits().ReshapeToUint64s()
56 a0 := word.GetElem(0)
57 b0 := word.GetElem(1)
58 return (a0|b0)&0x0001000100010001 != 0
59 }
60
61
62
63
64 func (x Mask16x8) None() bool {
65 word := x.ToInt16x8().ToBits().ReshapeToUint64s()
66 a0 := word.GetElem(0)
67 b0 := word.GetElem(1)
68 return (a0|b0)&0x0001000100010001 == 0
69 }
70
71
72
73
74 func (x Mask32x4) All() bool {
75 word := x.ToInt32x4().ToBits().ReshapeToUint64s()
76 a0 := word.GetElem(0)
77 b0 := word.GetElem(1)
78 return (a0&b0)&0x0000000100000001 == 0x0000000100000001
79 }
80
81
82
83
84 func (x Mask32x4) Any() bool {
85 word := x.ToInt32x4().ToBits().ReshapeToUint64s()
86 a0 := word.GetElem(0)
87 b0 := word.GetElem(1)
88 return (a0|b0)&0x0000000100000001 != 0
89 }
90
91
92
93
94 func (x Mask32x4) None() bool {
95 word := x.ToInt32x4().ToBits().ReshapeToUint64s()
96 a0 := word.GetElem(0)
97 b0 := word.GetElem(1)
98 return (a0|b0)&0x0000000100000001 == 0
99 }
100
101
102
103
104 func (x Mask64x2) All() bool {
105 word := x.ToInt64x2().ToBits()
106 a0 := word.GetElem(0)
107 b0 := word.GetElem(1)
108 return a0 != 0 && b0 != 0
109 }
110
111
112
113
114 func (x Mask64x2) Any() bool {
115 word := x.ToInt64x2().ToBits()
116 a0 := word.GetElem(0)
117 b0 := word.GetElem(1)
118 return a0 != 0 || b0 != 0
119 }
120
121
122
123
124 func (x Mask64x2) None() bool {
125 word := x.ToInt64x2().ToBits()
126 a0 := word.GetElem(0)
127 b0 := word.GetElem(1)
128 return a0 == 0 && b0 == 0
129 }
130
131
132
133
134
135 func (x Mask8x16) TrailingZeros() int {
136 word := x.ToInt8x16().ToBits().ReshapeToUint64s()
137 a0 := word.GetElem(0)
138 a := a0 & 0x0101010101010101
139 lane := bits.TrailingZeros64(a)
140 if lane < 64 {
141 return lane >> 3
142 }
143 a0 = word.GetElem(1)
144 a = a0 & 0x0101010101010101
145 lane = bits.TrailingZeros64(a)
146 return lane>>3 + 8
147 }
148
149
150
151
152
153 func (x Mask16x8) TrailingZeros() int {
154 word := x.ToInt16x8().ToBits().ReshapeToUint64s()
155 a0 := word.GetElem(0)
156 a := a0 & 0x0001000100010001
157 lane := bits.TrailingZeros64(a)
158 if lane < 64 {
159 return lane >> 4
160 }
161 a0 = word.GetElem(1)
162 a = a0 & 0x0001000100010001
163 lane = bits.TrailingZeros64(a)
164 return lane>>4 + 4
165 }
166
167
168
169
170
171 func (x Mask32x4) TrailingZeros() int {
172 word := x.ToInt32x4().ToBits().ReshapeToUint64s()
173 a0 := word.GetElem(0)
174 a := a0 & 0x0000000100000001
175 lane := bits.TrailingZeros64(a)
176 if lane < 64 {
177 return lane >> 5
178 }
179 a0 = word.GetElem(1)
180 a = a0 & 0x0000000100000001
181 lane = bits.TrailingZeros64(a)
182 return lane>>5 + 2
183 }
184
185
186
187
188
189 func (x Mask64x2) TrailingZeros() int {
190 word := x.ToInt64x2().ToBits()
191 if word.GetElem(0) != 0 {
192 return 0
193 }
194 if word.GetElem(1) != 0 {
195 return 1
196 }
197 return 2
198 }
199
View as plain text