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 func (x Mask8x16) TrailingZeros() int {
135 word := x.ToInt8x16().ToBits().ReshapeToUint64s()
136 a0 := word.GetElem(0)
137 a := a0 & 0x0101010101010101
138 lane := bits.TrailingZeros64(a)
139 if lane < 64 {
140 return lane >> 3
141 }
142 a0 = word.GetElem(1)
143 a = a0 & 0x0101010101010101
144 lane = bits.TrailingZeros64(a)
145 return lane>>3 + 8
146 }
147
148
149
150
151 func (x Mask16x8) TrailingZeros() int {
152 word := x.ToInt16x8().ToBits().ReshapeToUint64s()
153 a0 := word.GetElem(0)
154 a := a0 & 0x0001000100010001
155 lane := bits.TrailingZeros64(a)
156 if lane < 64 {
157 return lane >> 4
158 }
159 a0 = word.GetElem(1)
160 a = a0 & 0x0001000100010001
161 lane = bits.TrailingZeros64(a)
162 return lane>>4 + 4
163 }
164
165
166
167
168 func (x Mask32x4) TrailingZeros() int {
169 word := x.ToInt32x4().ToBits().ReshapeToUint64s()
170 a0 := word.GetElem(0)
171 a := a0 & 0x0000000100000001
172 lane := bits.TrailingZeros64(a)
173 if lane < 64 {
174 return lane >> 5
175 }
176 a0 = word.GetElem(1)
177 a = a0 & 0x0000000100000001
178 lane = bits.TrailingZeros64(a)
179 return lane>>5 + 2
180 }
181
182
183
184
185 func (x Mask64x2) TrailingZeros() int {
186 word := x.ToInt64x2().ToBits()
187 if word.GetElem(0) != 0 {
188 return 0
189 }
190 if word.GetElem(1) != 0 {
191 return 1
192 }
193 return 2
194 }
195
View as plain text