1
2
3 package rewritedivisible
4
5 import "cmd/compile/internal/ssa/ssaop"
6 import "cmd/compile/internal/ssa"
7
8 func RewriteValue(v *ssa.Value) bool {
9 switch v.Op {
10 case ssaop.OpEq16:
11 return rewriteValue_OpEq16(v)
12 case ssaop.OpEq32:
13 return rewriteValue_OpEq32(v)
14 case ssaop.OpEq64:
15 return rewriteValue_OpEq64(v)
16 case ssaop.OpEq8:
17 return rewriteValue_OpEq8(v)
18 case ssaop.OpNeq16:
19 return rewriteValue_OpNeq16(v)
20 case ssaop.OpNeq32:
21 return rewriteValue_OpNeq32(v)
22 case ssaop.OpNeq64:
23 return rewriteValue_OpNeq64(v)
24 case ssaop.OpNeq8:
25 return rewriteValue_OpNeq8(v)
26 }
27 return false
28 }
29 func rewriteValue_OpEq16(v *ssa.Value) bool {
30 v_1 := v.Args[1]
31 v_0 := v.Args[0]
32 b := v.Block
33
34
35
36 for {
37 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
38 x := v_0
39 if v_1.Op != ssaop.OpMul16 {
40 continue
41 }
42 t := v_1.Type
43 _ = v_1.Args[1]
44 v_1_0 := v_1.Args[0]
45 v_1_1 := v_1.Args[1]
46 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
47 if v_1_0.Op != ssaop.OpDiv16u {
48 continue
49 }
50 _ = v_1_0.Args[1]
51 if x != v_1_0.Args[0] {
52 continue
53 }
54 v_1_0_1 := v_1_0.Args[1]
55 if v_1_0_1.Op != ssaop.OpConst16 {
56 continue
57 }
58 c := ssa.AuxIntToInt16(v_1_0_1.AuxInt)
59 if v_1_1.Op != ssaop.OpConst16 || ssa.AuxIntToInt16(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
60 continue
61 }
62 v.Reset(ssaop.OpEq16)
63 v0 := b.NewValue0(v.Pos, ssaop.OpAnd16, t)
64 v1 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
65 v1.AuxInt = ssa.Int16ToAuxInt(c - 1)
66 v0.AddArg2(x, v1)
67 v2 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
68 v2.AuxInt = ssa.Int16ToAuxInt(0)
69 v.AddArg2(v0, v2)
70 return true
71 }
72 }
73 break
74 }
75
76
77
78 for {
79 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
80 x := v_0
81 if v_1.Op != ssaop.OpMul16 {
82 continue
83 }
84 t := v_1.Type
85 _ = v_1.Args[1]
86 v_1_0 := v_1.Args[0]
87 v_1_1 := v_1.Args[1]
88 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
89 if v_1_0.Op != ssaop.OpDiv16 {
90 continue
91 }
92 _ = v_1_0.Args[1]
93 if x != v_1_0.Args[0] {
94 continue
95 }
96 v_1_0_1 := v_1_0.Args[1]
97 if v_1_0_1.Op != ssaop.OpConst16 {
98 continue
99 }
100 c := ssa.AuxIntToInt16(v_1_0_1.AuxInt)
101 if v_1_1.Op != ssaop.OpConst16 || ssa.AuxIntToInt16(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
102 continue
103 }
104 v.Reset(ssaop.OpEq16)
105 v0 := b.NewValue0(v.Pos, ssaop.OpAnd16, t)
106 v1 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
107 v1.AuxInt = ssa.Int16ToAuxInt(c - 1)
108 v0.AddArg2(x, v1)
109 v2 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
110 v2.AuxInt = ssa.Int16ToAuxInt(0)
111 v.AddArg2(v0, v2)
112 return true
113 }
114 }
115 break
116 }
117
118
119
120 for {
121 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
122 x := v_0
123 if v_1.Op != ssaop.OpMul16 {
124 continue
125 }
126 t := v_1.Type
127 _ = v_1.Args[1]
128 v_1_0 := v_1.Args[0]
129 v_1_1 := v_1.Args[1]
130 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
131 div := v_1_0
132 if div.Op != ssaop.OpDiv16u {
133 continue
134 }
135 _ = div.Args[1]
136 if x != div.Args[0] {
137 continue
138 }
139 div_1 := div.Args[1]
140 if div_1.Op != ssaop.OpConst16 {
141 continue
142 }
143 c := ssa.AuxIntToInt16(div_1.AuxInt)
144 if v_1_1.Op != ssaop.OpConst16 || ssa.AuxIntToInt16(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst16 && ssa.UdivisibleOK16(c)) {
145 continue
146 }
147 v.Reset(ssaop.OpLeq16U)
148 v0 := b.NewValue0(v.Pos, ssaop.OpRotateLeft16, t)
149 v1 := b.NewValue0(v.Pos, ssaop.OpMul16, t)
150 v2 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
151 v2.AuxInt = ssa.Int16ToAuxInt(int16(udivisible16(c).M))
152 v1.AddArg2(x, v2)
153 v3 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
154 v3.AuxInt = ssa.Int16ToAuxInt(int16(16 - udivisible16(c).K))
155 v0.AddArg2(v1, v3)
156 v4 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
157 v4.AuxInt = ssa.Int16ToAuxInt(int16(udivisible16(c).Max))
158 v.AddArg2(v0, v4)
159 return true
160 }
161 }
162 break
163 }
164
165
166
167 for {
168 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
169 x := v_0
170 if v_1.Op != ssaop.OpMul16 {
171 continue
172 }
173 t := v_1.Type
174 _ = v_1.Args[1]
175 v_1_0 := v_1.Args[0]
176 v_1_1 := v_1.Args[1]
177 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
178 div := v_1_0
179 if div.Op != ssaop.OpDiv16 {
180 continue
181 }
182 _ = div.Args[1]
183 if x != div.Args[0] {
184 continue
185 }
186 div_1 := div.Args[1]
187 if div_1.Op != ssaop.OpConst16 {
188 continue
189 }
190 c := ssa.AuxIntToInt16(div_1.AuxInt)
191 if v_1_1.Op != ssaop.OpConst16 || ssa.AuxIntToInt16(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst16 && ssa.SdivisibleOK16(c)) {
192 continue
193 }
194 v.Reset(ssaop.OpLeq16U)
195 v0 := b.NewValue0(v.Pos, ssaop.OpRotateLeft16, t)
196 v1 := b.NewValue0(v.Pos, ssaop.OpAdd16, t)
197 v2 := b.NewValue0(v.Pos, ssaop.OpMul16, t)
198 v3 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
199 v3.AuxInt = ssa.Int16ToAuxInt(int16(sdivisible16(c).M))
200 v2.AddArg2(x, v3)
201 v4 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
202 v4.AuxInt = ssa.Int16ToAuxInt(int16(sdivisible16(c).A))
203 v1.AddArg2(v2, v4)
204 v5 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
205 v5.AuxInt = ssa.Int16ToAuxInt(int16(16 - sdivisible16(c).K))
206 v0.AddArg2(v1, v5)
207 v6 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
208 v6.AuxInt = ssa.Int16ToAuxInt(int16(sdivisible16(c).Max))
209 v.AddArg2(v0, v6)
210 return true
211 }
212 }
213 break
214 }
215 return false
216 }
217 func rewriteValue_OpEq32(v *ssa.Value) bool {
218 v_1 := v.Args[1]
219 v_0 := v.Args[0]
220 b := v.Block
221
222
223
224 for {
225 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
226 x := v_0
227 if v_1.Op != ssaop.OpMul32 {
228 continue
229 }
230 t := v_1.Type
231 _ = v_1.Args[1]
232 v_1_0 := v_1.Args[0]
233 v_1_1 := v_1.Args[1]
234 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
235 if v_1_0.Op != ssaop.OpDiv32u {
236 continue
237 }
238 _ = v_1_0.Args[1]
239 if x != v_1_0.Args[0] {
240 continue
241 }
242 v_1_0_1 := v_1_0.Args[1]
243 if v_1_0_1.Op != ssaop.OpConst32 {
244 continue
245 }
246 c := ssa.AuxIntToInt32(v_1_0_1.AuxInt)
247 if v_1_1.Op != ssaop.OpConst32 || ssa.AuxIntToInt32(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
248 continue
249 }
250 v.Reset(ssaop.OpEq32)
251 v0 := b.NewValue0(v.Pos, ssaop.OpAnd32, t)
252 v1 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
253 v1.AuxInt = ssa.Int32ToAuxInt(c - 1)
254 v0.AddArg2(x, v1)
255 v2 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
256 v2.AuxInt = ssa.Int32ToAuxInt(0)
257 v.AddArg2(v0, v2)
258 return true
259 }
260 }
261 break
262 }
263
264
265
266 for {
267 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
268 x := v_0
269 if v_1.Op != ssaop.OpMul32 {
270 continue
271 }
272 t := v_1.Type
273 _ = v_1.Args[1]
274 v_1_0 := v_1.Args[0]
275 v_1_1 := v_1.Args[1]
276 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
277 if v_1_0.Op != ssaop.OpDiv32 {
278 continue
279 }
280 _ = v_1_0.Args[1]
281 if x != v_1_0.Args[0] {
282 continue
283 }
284 v_1_0_1 := v_1_0.Args[1]
285 if v_1_0_1.Op != ssaop.OpConst32 {
286 continue
287 }
288 c := ssa.AuxIntToInt32(v_1_0_1.AuxInt)
289 if v_1_1.Op != ssaop.OpConst32 || ssa.AuxIntToInt32(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
290 continue
291 }
292 v.Reset(ssaop.OpEq32)
293 v0 := b.NewValue0(v.Pos, ssaop.OpAnd32, t)
294 v1 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
295 v1.AuxInt = ssa.Int32ToAuxInt(c - 1)
296 v0.AddArg2(x, v1)
297 v2 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
298 v2.AuxInt = ssa.Int32ToAuxInt(0)
299 v.AddArg2(v0, v2)
300 return true
301 }
302 }
303 break
304 }
305
306
307
308 for {
309 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
310 x := v_0
311 if v_1.Op != ssaop.OpMul32 {
312 continue
313 }
314 t := v_1.Type
315 _ = v_1.Args[1]
316 v_1_0 := v_1.Args[0]
317 v_1_1 := v_1.Args[1]
318 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
319 div := v_1_0
320 if div.Op != ssaop.OpDiv32u {
321 continue
322 }
323 _ = div.Args[1]
324 if x != div.Args[0] {
325 continue
326 }
327 div_1 := div.Args[1]
328 if div_1.Op != ssaop.OpConst32 {
329 continue
330 }
331 c := ssa.AuxIntToInt32(div_1.AuxInt)
332 if v_1_1.Op != ssaop.OpConst32 || ssa.AuxIntToInt32(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst32 && udivisibleOK32(c)) {
333 continue
334 }
335 v.Reset(ssaop.OpLeq32U)
336 v0 := b.NewValue0(v.Pos, ssaop.OpRotateLeft32, t)
337 v1 := b.NewValue0(v.Pos, ssaop.OpMul32, t)
338 v2 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
339 v2.AuxInt = ssa.Int32ToAuxInt(int32(udivisible32(c).M))
340 v1.AddArg2(x, v2)
341 v3 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
342 v3.AuxInt = ssa.Int32ToAuxInt(int32(32 - udivisible32(c).K))
343 v0.AddArg2(v1, v3)
344 v4 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
345 v4.AuxInt = ssa.Int32ToAuxInt(int32(udivisible32(c).Max))
346 v.AddArg2(v0, v4)
347 return true
348 }
349 }
350 break
351 }
352
353
354
355 for {
356 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
357 x := v_0
358 if v_1.Op != ssaop.OpMul32 {
359 continue
360 }
361 t := v_1.Type
362 _ = v_1.Args[1]
363 v_1_0 := v_1.Args[0]
364 v_1_1 := v_1.Args[1]
365 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
366 div := v_1_0
367 if div.Op != ssaop.OpDiv32 {
368 continue
369 }
370 _ = div.Args[1]
371 if x != div.Args[0] {
372 continue
373 }
374 div_1 := div.Args[1]
375 if div_1.Op != ssaop.OpConst32 {
376 continue
377 }
378 c := ssa.AuxIntToInt32(div_1.AuxInt)
379 if v_1_1.Op != ssaop.OpConst32 || ssa.AuxIntToInt32(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst32 && sdivisibleOK32(c)) {
380 continue
381 }
382 v.Reset(ssaop.OpLeq32U)
383 v0 := b.NewValue0(v.Pos, ssaop.OpRotateLeft32, t)
384 v1 := b.NewValue0(v.Pos, ssaop.OpAdd32, t)
385 v2 := b.NewValue0(v.Pos, ssaop.OpMul32, t)
386 v3 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
387 v3.AuxInt = ssa.Int32ToAuxInt(int32(sdivisible32(c).M))
388 v2.AddArg2(x, v3)
389 v4 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
390 v4.AuxInt = ssa.Int32ToAuxInt(int32(sdivisible32(c).A))
391 v1.AddArg2(v2, v4)
392 v5 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
393 v5.AuxInt = ssa.Int32ToAuxInt(int32(32 - sdivisible32(c).K))
394 v0.AddArg2(v1, v5)
395 v6 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
396 v6.AuxInt = ssa.Int32ToAuxInt(int32(sdivisible32(c).Max))
397 v.AddArg2(v0, v6)
398 return true
399 }
400 }
401 break
402 }
403 return false
404 }
405 func rewriteValue_OpEq64(v *ssa.Value) bool {
406 v_1 := v.Args[1]
407 v_0 := v.Args[0]
408 b := v.Block
409
410
411
412 for {
413 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
414 x := v_0
415 if v_1.Op != ssaop.OpMul64 {
416 continue
417 }
418 t := v_1.Type
419 _ = v_1.Args[1]
420 v_1_0 := v_1.Args[0]
421 v_1_1 := v_1.Args[1]
422 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
423 if v_1_0.Op != ssaop.OpDiv64u {
424 continue
425 }
426 _ = v_1_0.Args[1]
427 if x != v_1_0.Args[0] {
428 continue
429 }
430 v_1_0_1 := v_1_0.Args[1]
431 if v_1_0_1.Op != ssaop.OpConst64 {
432 continue
433 }
434 c := ssa.AuxIntToInt64(v_1_0_1.AuxInt)
435 if v_1_1.Op != ssaop.OpConst64 || ssa.AuxIntToInt64(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
436 continue
437 }
438 v.Reset(ssaop.OpEq64)
439 v0 := b.NewValue0(v.Pos, ssaop.OpAnd64, t)
440 v1 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
441 v1.AuxInt = ssa.Int64ToAuxInt(c - 1)
442 v0.AddArg2(x, v1)
443 v2 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
444 v2.AuxInt = ssa.Int64ToAuxInt(0)
445 v.AddArg2(v0, v2)
446 return true
447 }
448 }
449 break
450 }
451
452
453
454 for {
455 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
456 x := v_0
457 if v_1.Op != ssaop.OpMul64 {
458 continue
459 }
460 t := v_1.Type
461 _ = v_1.Args[1]
462 v_1_0 := v_1.Args[0]
463 v_1_1 := v_1.Args[1]
464 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
465 if v_1_0.Op != ssaop.OpDiv64 {
466 continue
467 }
468 _ = v_1_0.Args[1]
469 if x != v_1_0.Args[0] {
470 continue
471 }
472 v_1_0_1 := v_1_0.Args[1]
473 if v_1_0_1.Op != ssaop.OpConst64 {
474 continue
475 }
476 c := ssa.AuxIntToInt64(v_1_0_1.AuxInt)
477 if v_1_1.Op != ssaop.OpConst64 || ssa.AuxIntToInt64(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
478 continue
479 }
480 v.Reset(ssaop.OpEq64)
481 v0 := b.NewValue0(v.Pos, ssaop.OpAnd64, t)
482 v1 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
483 v1.AuxInt = ssa.Int64ToAuxInt(c - 1)
484 v0.AddArg2(x, v1)
485 v2 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
486 v2.AuxInt = ssa.Int64ToAuxInt(0)
487 v.AddArg2(v0, v2)
488 return true
489 }
490 }
491 break
492 }
493
494
495
496 for {
497 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
498 x := v_0
499 if v_1.Op != ssaop.OpMul64 {
500 continue
501 }
502 t := v_1.Type
503 _ = v_1.Args[1]
504 v_1_0 := v_1.Args[0]
505 v_1_1 := v_1.Args[1]
506 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
507 div := v_1_0
508 if div.Op != ssaop.OpDiv64u {
509 continue
510 }
511 _ = div.Args[1]
512 if x != div.Args[0] {
513 continue
514 }
515 div_1 := div.Args[1]
516 if div_1.Op != ssaop.OpConst64 {
517 continue
518 }
519 c := ssa.AuxIntToInt64(div_1.AuxInt)
520 if v_1_1.Op != ssaop.OpConst64 || ssa.AuxIntToInt64(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst64 && udivisibleOK64(c)) {
521 continue
522 }
523 v.Reset(ssaop.OpLeq64U)
524 v0 := b.NewValue0(v.Pos, ssaop.OpRotateLeft64, t)
525 v1 := b.NewValue0(v.Pos, ssaop.OpMul64, t)
526 v2 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
527 v2.AuxInt = ssa.Int64ToAuxInt(int64(udivisible64(c).M))
528 v1.AddArg2(x, v2)
529 v3 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
530 v3.AuxInt = ssa.Int64ToAuxInt(int64(64 - udivisible64(c).K))
531 v0.AddArg2(v1, v3)
532 v4 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
533 v4.AuxInt = ssa.Int64ToAuxInt(int64(udivisible64(c).Max))
534 v.AddArg2(v0, v4)
535 return true
536 }
537 }
538 break
539 }
540
541
542
543 for {
544 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
545 x := v_0
546 if v_1.Op != ssaop.OpMul64 {
547 continue
548 }
549 t := v_1.Type
550 _ = v_1.Args[1]
551 v_1_0 := v_1.Args[0]
552 v_1_1 := v_1.Args[1]
553 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
554 div := v_1_0
555 if div.Op != ssaop.OpDiv64 {
556 continue
557 }
558 _ = div.Args[1]
559 if x != div.Args[0] {
560 continue
561 }
562 div_1 := div.Args[1]
563 if div_1.Op != ssaop.OpConst64 {
564 continue
565 }
566 c := ssa.AuxIntToInt64(div_1.AuxInt)
567 if v_1_1.Op != ssaop.OpConst64 || ssa.AuxIntToInt64(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst64 && sdivisibleOK64(c)) {
568 continue
569 }
570 v.Reset(ssaop.OpLeq64U)
571 v0 := b.NewValue0(v.Pos, ssaop.OpRotateLeft64, t)
572 v1 := b.NewValue0(v.Pos, ssaop.OpAdd64, t)
573 v2 := b.NewValue0(v.Pos, ssaop.OpMul64, t)
574 v3 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
575 v3.AuxInt = ssa.Int64ToAuxInt(int64(sdivisible64(c).M))
576 v2.AddArg2(x, v3)
577 v4 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
578 v4.AuxInt = ssa.Int64ToAuxInt(int64(sdivisible64(c).A))
579 v1.AddArg2(v2, v4)
580 v5 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
581 v5.AuxInt = ssa.Int64ToAuxInt(int64(64 - sdivisible64(c).K))
582 v0.AddArg2(v1, v5)
583 v6 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
584 v6.AuxInt = ssa.Int64ToAuxInt(int64(sdivisible64(c).Max))
585 v.AddArg2(v0, v6)
586 return true
587 }
588 }
589 break
590 }
591 return false
592 }
593 func rewriteValue_OpEq8(v *ssa.Value) bool {
594 v_1 := v.Args[1]
595 v_0 := v.Args[0]
596 b := v.Block
597
598
599
600 for {
601 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
602 x := v_0
603 if v_1.Op != ssaop.OpMul8 {
604 continue
605 }
606 t := v_1.Type
607 _ = v_1.Args[1]
608 v_1_0 := v_1.Args[0]
609 v_1_1 := v_1.Args[1]
610 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
611 if v_1_0.Op != ssaop.OpDiv8u {
612 continue
613 }
614 _ = v_1_0.Args[1]
615 if x != v_1_0.Args[0] {
616 continue
617 }
618 v_1_0_1 := v_1_0.Args[1]
619 if v_1_0_1.Op != ssaop.OpConst8 {
620 continue
621 }
622 c := ssa.AuxIntToInt8(v_1_0_1.AuxInt)
623 if v_1_1.Op != ssaop.OpConst8 || ssa.AuxIntToInt8(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
624 continue
625 }
626 v.Reset(ssaop.OpEq8)
627 v0 := b.NewValue0(v.Pos, ssaop.OpAnd8, t)
628 v1 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
629 v1.AuxInt = ssa.Int8ToAuxInt(c - 1)
630 v0.AddArg2(x, v1)
631 v2 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
632 v2.AuxInt = ssa.Int8ToAuxInt(0)
633 v.AddArg2(v0, v2)
634 return true
635 }
636 }
637 break
638 }
639
640
641
642 for {
643 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
644 x := v_0
645 if v_1.Op != ssaop.OpMul8 {
646 continue
647 }
648 t := v_1.Type
649 _ = v_1.Args[1]
650 v_1_0 := v_1.Args[0]
651 v_1_1 := v_1.Args[1]
652 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
653 if v_1_0.Op != ssaop.OpDiv8 {
654 continue
655 }
656 _ = v_1_0.Args[1]
657 if x != v_1_0.Args[0] {
658 continue
659 }
660 v_1_0_1 := v_1_0.Args[1]
661 if v_1_0_1.Op != ssaop.OpConst8 {
662 continue
663 }
664 c := ssa.AuxIntToInt8(v_1_0_1.AuxInt)
665 if v_1_1.Op != ssaop.OpConst8 || ssa.AuxIntToInt8(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
666 continue
667 }
668 v.Reset(ssaop.OpEq8)
669 v0 := b.NewValue0(v.Pos, ssaop.OpAnd8, t)
670 v1 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
671 v1.AuxInt = ssa.Int8ToAuxInt(c - 1)
672 v0.AddArg2(x, v1)
673 v2 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
674 v2.AuxInt = ssa.Int8ToAuxInt(0)
675 v.AddArg2(v0, v2)
676 return true
677 }
678 }
679 break
680 }
681
682
683
684 for {
685 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
686 x := v_0
687 if v_1.Op != ssaop.OpMul8 {
688 continue
689 }
690 t := v_1.Type
691 _ = v_1.Args[1]
692 v_1_0 := v_1.Args[0]
693 v_1_1 := v_1.Args[1]
694 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
695 div := v_1_0
696 if div.Op != ssaop.OpDiv8u {
697 continue
698 }
699 _ = div.Args[1]
700 if x != div.Args[0] {
701 continue
702 }
703 div_1 := div.Args[1]
704 if div_1.Op != ssaop.OpConst8 {
705 continue
706 }
707 c := ssa.AuxIntToInt8(div_1.AuxInt)
708 if v_1_1.Op != ssaop.OpConst8 || ssa.AuxIntToInt8(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst8 && ssa.UdivisibleOK8(c)) {
709 continue
710 }
711 v.Reset(ssaop.OpLeq8U)
712 v0 := b.NewValue0(v.Pos, ssaop.OpRotateLeft8, t)
713 v1 := b.NewValue0(v.Pos, ssaop.OpMul8, t)
714 v2 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
715 v2.AuxInt = ssa.Int8ToAuxInt(int8(udivisible8(c).M))
716 v1.AddArg2(x, v2)
717 v3 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
718 v3.AuxInt = ssa.Int8ToAuxInt(int8(8 - udivisible8(c).K))
719 v0.AddArg2(v1, v3)
720 v4 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
721 v4.AuxInt = ssa.Int8ToAuxInt(int8(udivisible8(c).Max))
722 v.AddArg2(v0, v4)
723 return true
724 }
725 }
726 break
727 }
728
729
730
731 for {
732 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
733 x := v_0
734 if v_1.Op != ssaop.OpMul8 {
735 continue
736 }
737 t := v_1.Type
738 _ = v_1.Args[1]
739 v_1_0 := v_1.Args[0]
740 v_1_1 := v_1.Args[1]
741 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
742 div := v_1_0
743 if div.Op != ssaop.OpDiv8 {
744 continue
745 }
746 _ = div.Args[1]
747 if x != div.Args[0] {
748 continue
749 }
750 div_1 := div.Args[1]
751 if div_1.Op != ssaop.OpConst8 {
752 continue
753 }
754 c := ssa.AuxIntToInt8(div_1.AuxInt)
755 if v_1_1.Op != ssaop.OpConst8 || ssa.AuxIntToInt8(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst8 && ssa.SdivisibleOK8(c)) {
756 continue
757 }
758 v.Reset(ssaop.OpLeq8U)
759 v0 := b.NewValue0(v.Pos, ssaop.OpRotateLeft8, t)
760 v1 := b.NewValue0(v.Pos, ssaop.OpAdd8, t)
761 v2 := b.NewValue0(v.Pos, ssaop.OpMul8, t)
762 v3 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
763 v3.AuxInt = ssa.Int8ToAuxInt(int8(sdivisible8(c).M))
764 v2.AddArg2(x, v3)
765 v4 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
766 v4.AuxInt = ssa.Int8ToAuxInt(int8(sdivisible8(c).A))
767 v1.AddArg2(v2, v4)
768 v5 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
769 v5.AuxInt = ssa.Int8ToAuxInt(int8(8 - sdivisible8(c).K))
770 v0.AddArg2(v1, v5)
771 v6 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
772 v6.AuxInt = ssa.Int8ToAuxInt(int8(sdivisible8(c).Max))
773 v.AddArg2(v0, v6)
774 return true
775 }
776 }
777 break
778 }
779 return false
780 }
781 func rewriteValue_OpNeq16(v *ssa.Value) bool {
782 v_1 := v.Args[1]
783 v_0 := v.Args[0]
784 b := v.Block
785
786
787
788 for {
789 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
790 x := v_0
791 if v_1.Op != ssaop.OpMul16 {
792 continue
793 }
794 t := v_1.Type
795 _ = v_1.Args[1]
796 v_1_0 := v_1.Args[0]
797 v_1_1 := v_1.Args[1]
798 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
799 if v_1_0.Op != ssaop.OpDiv16u {
800 continue
801 }
802 _ = v_1_0.Args[1]
803 if x != v_1_0.Args[0] {
804 continue
805 }
806 v_1_0_1 := v_1_0.Args[1]
807 if v_1_0_1.Op != ssaop.OpConst16 {
808 continue
809 }
810 c := ssa.AuxIntToInt16(v_1_0_1.AuxInt)
811 if v_1_1.Op != ssaop.OpConst16 || ssa.AuxIntToInt16(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
812 continue
813 }
814 v.Reset(ssaop.OpNeq16)
815 v0 := b.NewValue0(v.Pos, ssaop.OpAnd16, t)
816 v1 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
817 v1.AuxInt = ssa.Int16ToAuxInt(c - 1)
818 v0.AddArg2(x, v1)
819 v2 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
820 v2.AuxInt = ssa.Int16ToAuxInt(0)
821 v.AddArg2(v0, v2)
822 return true
823 }
824 }
825 break
826 }
827
828
829
830 for {
831 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
832 x := v_0
833 if v_1.Op != ssaop.OpMul16 {
834 continue
835 }
836 t := v_1.Type
837 _ = v_1.Args[1]
838 v_1_0 := v_1.Args[0]
839 v_1_1 := v_1.Args[1]
840 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
841 if v_1_0.Op != ssaop.OpDiv16 {
842 continue
843 }
844 _ = v_1_0.Args[1]
845 if x != v_1_0.Args[0] {
846 continue
847 }
848 v_1_0_1 := v_1_0.Args[1]
849 if v_1_0_1.Op != ssaop.OpConst16 {
850 continue
851 }
852 c := ssa.AuxIntToInt16(v_1_0_1.AuxInt)
853 if v_1_1.Op != ssaop.OpConst16 || ssa.AuxIntToInt16(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
854 continue
855 }
856 v.Reset(ssaop.OpNeq16)
857 v0 := b.NewValue0(v.Pos, ssaop.OpAnd16, t)
858 v1 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
859 v1.AuxInt = ssa.Int16ToAuxInt(c - 1)
860 v0.AddArg2(x, v1)
861 v2 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
862 v2.AuxInt = ssa.Int16ToAuxInt(0)
863 v.AddArg2(v0, v2)
864 return true
865 }
866 }
867 break
868 }
869
870
871
872 for {
873 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
874 x := v_0
875 if v_1.Op != ssaop.OpMul16 {
876 continue
877 }
878 t := v_1.Type
879 _ = v_1.Args[1]
880 v_1_0 := v_1.Args[0]
881 v_1_1 := v_1.Args[1]
882 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
883 div := v_1_0
884 if div.Op != ssaop.OpDiv16u {
885 continue
886 }
887 _ = div.Args[1]
888 if x != div.Args[0] {
889 continue
890 }
891 div_1 := div.Args[1]
892 if div_1.Op != ssaop.OpConst16 {
893 continue
894 }
895 c := ssa.AuxIntToInt16(div_1.AuxInt)
896 if v_1_1.Op != ssaop.OpConst16 || ssa.AuxIntToInt16(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst16 && ssa.UdivisibleOK16(c)) {
897 continue
898 }
899 v.Reset(ssaop.OpLess16U)
900 v0 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
901 v0.AuxInt = ssa.Int16ToAuxInt(int16(udivisible16(c).Max))
902 v1 := b.NewValue0(v.Pos, ssaop.OpRotateLeft16, t)
903 v2 := b.NewValue0(v.Pos, ssaop.OpMul16, t)
904 v3 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
905 v3.AuxInt = ssa.Int16ToAuxInt(int16(udivisible16(c).M))
906 v2.AddArg2(x, v3)
907 v4 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
908 v4.AuxInt = ssa.Int16ToAuxInt(int16(16 - udivisible16(c).K))
909 v1.AddArg2(v2, v4)
910 v.AddArg2(v0, v1)
911 return true
912 }
913 }
914 break
915 }
916
917
918
919 for {
920 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
921 x := v_0
922 if v_1.Op != ssaop.OpMul16 {
923 continue
924 }
925 t := v_1.Type
926 _ = v_1.Args[1]
927 v_1_0 := v_1.Args[0]
928 v_1_1 := v_1.Args[1]
929 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
930 div := v_1_0
931 if div.Op != ssaop.OpDiv16 {
932 continue
933 }
934 _ = div.Args[1]
935 if x != div.Args[0] {
936 continue
937 }
938 div_1 := div.Args[1]
939 if div_1.Op != ssaop.OpConst16 {
940 continue
941 }
942 c := ssa.AuxIntToInt16(div_1.AuxInt)
943 if v_1_1.Op != ssaop.OpConst16 || ssa.AuxIntToInt16(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst16 && ssa.SdivisibleOK16(c)) {
944 continue
945 }
946 v.Reset(ssaop.OpLess16U)
947 v0 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
948 v0.AuxInt = ssa.Int16ToAuxInt(int16(sdivisible16(c).Max))
949 v1 := b.NewValue0(v.Pos, ssaop.OpRotateLeft16, t)
950 v2 := b.NewValue0(v.Pos, ssaop.OpAdd16, t)
951 v3 := b.NewValue0(v.Pos, ssaop.OpMul16, t)
952 v4 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
953 v4.AuxInt = ssa.Int16ToAuxInt(int16(sdivisible16(c).M))
954 v3.AddArg2(x, v4)
955 v5 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
956 v5.AuxInt = ssa.Int16ToAuxInt(int16(sdivisible16(c).A))
957 v2.AddArg2(v3, v5)
958 v6 := b.NewValue0(v.Pos, ssaop.OpConst16, t)
959 v6.AuxInt = ssa.Int16ToAuxInt(int16(16 - sdivisible16(c).K))
960 v1.AddArg2(v2, v6)
961 v.AddArg2(v0, v1)
962 return true
963 }
964 }
965 break
966 }
967 return false
968 }
969 func rewriteValue_OpNeq32(v *ssa.Value) bool {
970 v_1 := v.Args[1]
971 v_0 := v.Args[0]
972 b := v.Block
973
974
975
976 for {
977 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
978 x := v_0
979 if v_1.Op != ssaop.OpMul32 {
980 continue
981 }
982 t := v_1.Type
983 _ = v_1.Args[1]
984 v_1_0 := v_1.Args[0]
985 v_1_1 := v_1.Args[1]
986 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
987 if v_1_0.Op != ssaop.OpDiv32u {
988 continue
989 }
990 _ = v_1_0.Args[1]
991 if x != v_1_0.Args[0] {
992 continue
993 }
994 v_1_0_1 := v_1_0.Args[1]
995 if v_1_0_1.Op != ssaop.OpConst32 {
996 continue
997 }
998 c := ssa.AuxIntToInt32(v_1_0_1.AuxInt)
999 if v_1_1.Op != ssaop.OpConst32 || ssa.AuxIntToInt32(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
1000 continue
1001 }
1002 v.Reset(ssaop.OpNeq32)
1003 v0 := b.NewValue0(v.Pos, ssaop.OpAnd32, t)
1004 v1 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
1005 v1.AuxInt = ssa.Int32ToAuxInt(c - 1)
1006 v0.AddArg2(x, v1)
1007 v2 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
1008 v2.AuxInt = ssa.Int32ToAuxInt(0)
1009 v.AddArg2(v0, v2)
1010 return true
1011 }
1012 }
1013 break
1014 }
1015
1016
1017
1018 for {
1019 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
1020 x := v_0
1021 if v_1.Op != ssaop.OpMul32 {
1022 continue
1023 }
1024 t := v_1.Type
1025 _ = v_1.Args[1]
1026 v_1_0 := v_1.Args[0]
1027 v_1_1 := v_1.Args[1]
1028 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
1029 if v_1_0.Op != ssaop.OpDiv32 {
1030 continue
1031 }
1032 _ = v_1_0.Args[1]
1033 if x != v_1_0.Args[0] {
1034 continue
1035 }
1036 v_1_0_1 := v_1_0.Args[1]
1037 if v_1_0_1.Op != ssaop.OpConst32 {
1038 continue
1039 }
1040 c := ssa.AuxIntToInt32(v_1_0_1.AuxInt)
1041 if v_1_1.Op != ssaop.OpConst32 || ssa.AuxIntToInt32(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
1042 continue
1043 }
1044 v.Reset(ssaop.OpNeq32)
1045 v0 := b.NewValue0(v.Pos, ssaop.OpAnd32, t)
1046 v1 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
1047 v1.AuxInt = ssa.Int32ToAuxInt(c - 1)
1048 v0.AddArg2(x, v1)
1049 v2 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
1050 v2.AuxInt = ssa.Int32ToAuxInt(0)
1051 v.AddArg2(v0, v2)
1052 return true
1053 }
1054 }
1055 break
1056 }
1057
1058
1059
1060 for {
1061 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
1062 x := v_0
1063 if v_1.Op != ssaop.OpMul32 {
1064 continue
1065 }
1066 t := v_1.Type
1067 _ = v_1.Args[1]
1068 v_1_0 := v_1.Args[0]
1069 v_1_1 := v_1.Args[1]
1070 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
1071 div := v_1_0
1072 if div.Op != ssaop.OpDiv32u {
1073 continue
1074 }
1075 _ = div.Args[1]
1076 if x != div.Args[0] {
1077 continue
1078 }
1079 div_1 := div.Args[1]
1080 if div_1.Op != ssaop.OpConst32 {
1081 continue
1082 }
1083 c := ssa.AuxIntToInt32(div_1.AuxInt)
1084 if v_1_1.Op != ssaop.OpConst32 || ssa.AuxIntToInt32(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst32 && udivisibleOK32(c)) {
1085 continue
1086 }
1087 v.Reset(ssaop.OpLess32U)
1088 v0 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
1089 v0.AuxInt = ssa.Int32ToAuxInt(int32(udivisible32(c).Max))
1090 v1 := b.NewValue0(v.Pos, ssaop.OpRotateLeft32, t)
1091 v2 := b.NewValue0(v.Pos, ssaop.OpMul32, t)
1092 v3 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
1093 v3.AuxInt = ssa.Int32ToAuxInt(int32(udivisible32(c).M))
1094 v2.AddArg2(x, v3)
1095 v4 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
1096 v4.AuxInt = ssa.Int32ToAuxInt(int32(32 - udivisible32(c).K))
1097 v1.AddArg2(v2, v4)
1098 v.AddArg2(v0, v1)
1099 return true
1100 }
1101 }
1102 break
1103 }
1104
1105
1106
1107 for {
1108 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
1109 x := v_0
1110 if v_1.Op != ssaop.OpMul32 {
1111 continue
1112 }
1113 t := v_1.Type
1114 _ = v_1.Args[1]
1115 v_1_0 := v_1.Args[0]
1116 v_1_1 := v_1.Args[1]
1117 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
1118 div := v_1_0
1119 if div.Op != ssaop.OpDiv32 {
1120 continue
1121 }
1122 _ = div.Args[1]
1123 if x != div.Args[0] {
1124 continue
1125 }
1126 div_1 := div.Args[1]
1127 if div_1.Op != ssaop.OpConst32 {
1128 continue
1129 }
1130 c := ssa.AuxIntToInt32(div_1.AuxInt)
1131 if v_1_1.Op != ssaop.OpConst32 || ssa.AuxIntToInt32(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst32 && sdivisibleOK32(c)) {
1132 continue
1133 }
1134 v.Reset(ssaop.OpLess32U)
1135 v0 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
1136 v0.AuxInt = ssa.Int32ToAuxInt(int32(sdivisible32(c).Max))
1137 v1 := b.NewValue0(v.Pos, ssaop.OpRotateLeft32, t)
1138 v2 := b.NewValue0(v.Pos, ssaop.OpAdd32, t)
1139 v3 := b.NewValue0(v.Pos, ssaop.OpMul32, t)
1140 v4 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
1141 v4.AuxInt = ssa.Int32ToAuxInt(int32(sdivisible32(c).M))
1142 v3.AddArg2(x, v4)
1143 v5 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
1144 v5.AuxInt = ssa.Int32ToAuxInt(int32(sdivisible32(c).A))
1145 v2.AddArg2(v3, v5)
1146 v6 := b.NewValue0(v.Pos, ssaop.OpConst32, t)
1147 v6.AuxInt = ssa.Int32ToAuxInt(int32(32 - sdivisible32(c).K))
1148 v1.AddArg2(v2, v6)
1149 v.AddArg2(v0, v1)
1150 return true
1151 }
1152 }
1153 break
1154 }
1155 return false
1156 }
1157 func rewriteValue_OpNeq64(v *ssa.Value) bool {
1158 v_1 := v.Args[1]
1159 v_0 := v.Args[0]
1160 b := v.Block
1161
1162
1163
1164 for {
1165 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
1166 x := v_0
1167 if v_1.Op != ssaop.OpMul64 {
1168 continue
1169 }
1170 t := v_1.Type
1171 _ = v_1.Args[1]
1172 v_1_0 := v_1.Args[0]
1173 v_1_1 := v_1.Args[1]
1174 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
1175 if v_1_0.Op != ssaop.OpDiv64u {
1176 continue
1177 }
1178 _ = v_1_0.Args[1]
1179 if x != v_1_0.Args[0] {
1180 continue
1181 }
1182 v_1_0_1 := v_1_0.Args[1]
1183 if v_1_0_1.Op != ssaop.OpConst64 {
1184 continue
1185 }
1186 c := ssa.AuxIntToInt64(v_1_0_1.AuxInt)
1187 if v_1_1.Op != ssaop.OpConst64 || ssa.AuxIntToInt64(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
1188 continue
1189 }
1190 v.Reset(ssaop.OpNeq64)
1191 v0 := b.NewValue0(v.Pos, ssaop.OpAnd64, t)
1192 v1 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
1193 v1.AuxInt = ssa.Int64ToAuxInt(c - 1)
1194 v0.AddArg2(x, v1)
1195 v2 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
1196 v2.AuxInt = ssa.Int64ToAuxInt(0)
1197 v.AddArg2(v0, v2)
1198 return true
1199 }
1200 }
1201 break
1202 }
1203
1204
1205
1206 for {
1207 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
1208 x := v_0
1209 if v_1.Op != ssaop.OpMul64 {
1210 continue
1211 }
1212 t := v_1.Type
1213 _ = v_1.Args[1]
1214 v_1_0 := v_1.Args[0]
1215 v_1_1 := v_1.Args[1]
1216 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
1217 if v_1_0.Op != ssaop.OpDiv64 {
1218 continue
1219 }
1220 _ = v_1_0.Args[1]
1221 if x != v_1_0.Args[0] {
1222 continue
1223 }
1224 v_1_0_1 := v_1_0.Args[1]
1225 if v_1_0_1.Op != ssaop.OpConst64 {
1226 continue
1227 }
1228 c := ssa.AuxIntToInt64(v_1_0_1.AuxInt)
1229 if v_1_1.Op != ssaop.OpConst64 || ssa.AuxIntToInt64(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
1230 continue
1231 }
1232 v.Reset(ssaop.OpNeq64)
1233 v0 := b.NewValue0(v.Pos, ssaop.OpAnd64, t)
1234 v1 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
1235 v1.AuxInt = ssa.Int64ToAuxInt(c - 1)
1236 v0.AddArg2(x, v1)
1237 v2 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
1238 v2.AuxInt = ssa.Int64ToAuxInt(0)
1239 v.AddArg2(v0, v2)
1240 return true
1241 }
1242 }
1243 break
1244 }
1245
1246
1247
1248 for {
1249 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
1250 x := v_0
1251 if v_1.Op != ssaop.OpMul64 {
1252 continue
1253 }
1254 t := v_1.Type
1255 _ = v_1.Args[1]
1256 v_1_0 := v_1.Args[0]
1257 v_1_1 := v_1.Args[1]
1258 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
1259 div := v_1_0
1260 if div.Op != ssaop.OpDiv64u {
1261 continue
1262 }
1263 _ = div.Args[1]
1264 if x != div.Args[0] {
1265 continue
1266 }
1267 div_1 := div.Args[1]
1268 if div_1.Op != ssaop.OpConst64 {
1269 continue
1270 }
1271 c := ssa.AuxIntToInt64(div_1.AuxInt)
1272 if v_1_1.Op != ssaop.OpConst64 || ssa.AuxIntToInt64(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst64 && udivisibleOK64(c)) {
1273 continue
1274 }
1275 v.Reset(ssaop.OpLess64U)
1276 v0 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
1277 v0.AuxInt = ssa.Int64ToAuxInt(int64(udivisible64(c).Max))
1278 v1 := b.NewValue0(v.Pos, ssaop.OpRotateLeft64, t)
1279 v2 := b.NewValue0(v.Pos, ssaop.OpMul64, t)
1280 v3 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
1281 v3.AuxInt = ssa.Int64ToAuxInt(int64(udivisible64(c).M))
1282 v2.AddArg2(x, v3)
1283 v4 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
1284 v4.AuxInt = ssa.Int64ToAuxInt(int64(64 - udivisible64(c).K))
1285 v1.AddArg2(v2, v4)
1286 v.AddArg2(v0, v1)
1287 return true
1288 }
1289 }
1290 break
1291 }
1292
1293
1294
1295 for {
1296 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
1297 x := v_0
1298 if v_1.Op != ssaop.OpMul64 {
1299 continue
1300 }
1301 t := v_1.Type
1302 _ = v_1.Args[1]
1303 v_1_0 := v_1.Args[0]
1304 v_1_1 := v_1.Args[1]
1305 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
1306 div := v_1_0
1307 if div.Op != ssaop.OpDiv64 {
1308 continue
1309 }
1310 _ = div.Args[1]
1311 if x != div.Args[0] {
1312 continue
1313 }
1314 div_1 := div.Args[1]
1315 if div_1.Op != ssaop.OpConst64 {
1316 continue
1317 }
1318 c := ssa.AuxIntToInt64(div_1.AuxInt)
1319 if v_1_1.Op != ssaop.OpConst64 || ssa.AuxIntToInt64(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst64 && sdivisibleOK64(c)) {
1320 continue
1321 }
1322 v.Reset(ssaop.OpLess64U)
1323 v0 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
1324 v0.AuxInt = ssa.Int64ToAuxInt(int64(sdivisible64(c).Max))
1325 v1 := b.NewValue0(v.Pos, ssaop.OpRotateLeft64, t)
1326 v2 := b.NewValue0(v.Pos, ssaop.OpAdd64, t)
1327 v3 := b.NewValue0(v.Pos, ssaop.OpMul64, t)
1328 v4 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
1329 v4.AuxInt = ssa.Int64ToAuxInt(int64(sdivisible64(c).M))
1330 v3.AddArg2(x, v4)
1331 v5 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
1332 v5.AuxInt = ssa.Int64ToAuxInt(int64(sdivisible64(c).A))
1333 v2.AddArg2(v3, v5)
1334 v6 := b.NewValue0(v.Pos, ssaop.OpConst64, t)
1335 v6.AuxInt = ssa.Int64ToAuxInt(int64(64 - sdivisible64(c).K))
1336 v1.AddArg2(v2, v6)
1337 v.AddArg2(v0, v1)
1338 return true
1339 }
1340 }
1341 break
1342 }
1343 return false
1344 }
1345 func rewriteValue_OpNeq8(v *ssa.Value) bool {
1346 v_1 := v.Args[1]
1347 v_0 := v.Args[0]
1348 b := v.Block
1349
1350
1351
1352 for {
1353 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
1354 x := v_0
1355 if v_1.Op != ssaop.OpMul8 {
1356 continue
1357 }
1358 t := v_1.Type
1359 _ = v_1.Args[1]
1360 v_1_0 := v_1.Args[0]
1361 v_1_1 := v_1.Args[1]
1362 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
1363 if v_1_0.Op != ssaop.OpDiv8u {
1364 continue
1365 }
1366 _ = v_1_0.Args[1]
1367 if x != v_1_0.Args[0] {
1368 continue
1369 }
1370 v_1_0_1 := v_1_0.Args[1]
1371 if v_1_0_1.Op != ssaop.OpConst8 {
1372 continue
1373 }
1374 c := ssa.AuxIntToInt8(v_1_0_1.AuxInt)
1375 if v_1_1.Op != ssaop.OpConst8 || ssa.AuxIntToInt8(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
1376 continue
1377 }
1378 v.Reset(ssaop.OpNeq8)
1379 v0 := b.NewValue0(v.Pos, ssaop.OpAnd8, t)
1380 v1 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
1381 v1.AuxInt = ssa.Int8ToAuxInt(c - 1)
1382 v0.AddArg2(x, v1)
1383 v2 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
1384 v2.AuxInt = ssa.Int8ToAuxInt(0)
1385 v.AddArg2(v0, v2)
1386 return true
1387 }
1388 }
1389 break
1390 }
1391
1392
1393
1394 for {
1395 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
1396 x := v_0
1397 if v_1.Op != ssaop.OpMul8 {
1398 continue
1399 }
1400 t := v_1.Type
1401 _ = v_1.Args[1]
1402 v_1_0 := v_1.Args[0]
1403 v_1_1 := v_1.Args[1]
1404 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
1405 if v_1_0.Op != ssaop.OpDiv8 {
1406 continue
1407 }
1408 _ = v_1_0.Args[1]
1409 if x != v_1_0.Args[0] {
1410 continue
1411 }
1412 v_1_0_1 := v_1_0.Args[1]
1413 if v_1_0_1.Op != ssaop.OpConst8 {
1414 continue
1415 }
1416 c := ssa.AuxIntToInt8(v_1_0_1.AuxInt)
1417 if v_1_1.Op != ssaop.OpConst8 || ssa.AuxIntToInt8(v_1_1.AuxInt) != c || !(x.Op != ssaop.OpConst64 && ssa.IsPowerOfTwo(c)) {
1418 continue
1419 }
1420 v.Reset(ssaop.OpNeq8)
1421 v0 := b.NewValue0(v.Pos, ssaop.OpAnd8, t)
1422 v1 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
1423 v1.AuxInt = ssa.Int8ToAuxInt(c - 1)
1424 v0.AddArg2(x, v1)
1425 v2 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
1426 v2.AuxInt = ssa.Int8ToAuxInt(0)
1427 v.AddArg2(v0, v2)
1428 return true
1429 }
1430 }
1431 break
1432 }
1433
1434
1435
1436 for {
1437 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
1438 x := v_0
1439 if v_1.Op != ssaop.OpMul8 {
1440 continue
1441 }
1442 t := v_1.Type
1443 _ = v_1.Args[1]
1444 v_1_0 := v_1.Args[0]
1445 v_1_1 := v_1.Args[1]
1446 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
1447 div := v_1_0
1448 if div.Op != ssaop.OpDiv8u {
1449 continue
1450 }
1451 _ = div.Args[1]
1452 if x != div.Args[0] {
1453 continue
1454 }
1455 div_1 := div.Args[1]
1456 if div_1.Op != ssaop.OpConst8 {
1457 continue
1458 }
1459 c := ssa.AuxIntToInt8(div_1.AuxInt)
1460 if v_1_1.Op != ssaop.OpConst8 || ssa.AuxIntToInt8(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst8 && ssa.UdivisibleOK8(c)) {
1461 continue
1462 }
1463 v.Reset(ssaop.OpLess8U)
1464 v0 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
1465 v0.AuxInt = ssa.Int8ToAuxInt(int8(udivisible8(c).Max))
1466 v1 := b.NewValue0(v.Pos, ssaop.OpRotateLeft8, t)
1467 v2 := b.NewValue0(v.Pos, ssaop.OpMul8, t)
1468 v3 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
1469 v3.AuxInt = ssa.Int8ToAuxInt(int8(udivisible8(c).M))
1470 v2.AddArg2(x, v3)
1471 v4 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
1472 v4.AuxInt = ssa.Int8ToAuxInt(int8(8 - udivisible8(c).K))
1473 v1.AddArg2(v2, v4)
1474 v.AddArg2(v0, v1)
1475 return true
1476 }
1477 }
1478 break
1479 }
1480
1481
1482
1483 for {
1484 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
1485 x := v_0
1486 if v_1.Op != ssaop.OpMul8 {
1487 continue
1488 }
1489 t := v_1.Type
1490 _ = v_1.Args[1]
1491 v_1_0 := v_1.Args[0]
1492 v_1_1 := v_1.Args[1]
1493 for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 {
1494 div := v_1_0
1495 if div.Op != ssaop.OpDiv8 {
1496 continue
1497 }
1498 _ = div.Args[1]
1499 if x != div.Args[0] {
1500 continue
1501 }
1502 div_1 := div.Args[1]
1503 if div_1.Op != ssaop.OpConst8 {
1504 continue
1505 }
1506 c := ssa.AuxIntToInt8(div_1.AuxInt)
1507 if v_1_1.Op != ssaop.OpConst8 || ssa.AuxIntToInt8(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != ssaop.OpConst8 && ssa.SdivisibleOK8(c)) {
1508 continue
1509 }
1510 v.Reset(ssaop.OpLess8U)
1511 v0 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
1512 v0.AuxInt = ssa.Int8ToAuxInt(int8(sdivisible8(c).Max))
1513 v1 := b.NewValue0(v.Pos, ssaop.OpRotateLeft8, t)
1514 v2 := b.NewValue0(v.Pos, ssaop.OpAdd8, t)
1515 v3 := b.NewValue0(v.Pos, ssaop.OpMul8, t)
1516 v4 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
1517 v4.AuxInt = ssa.Int8ToAuxInt(int8(sdivisible8(c).M))
1518 v3.AddArg2(x, v4)
1519 v5 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
1520 v5.AuxInt = ssa.Int8ToAuxInt(int8(sdivisible8(c).A))
1521 v2.AddArg2(v3, v5)
1522 v6 := b.NewValue0(v.Pos, ssaop.OpConst8, t)
1523 v6.AuxInt = ssa.Int8ToAuxInt(int8(8 - sdivisible8(c).K))
1524 v1.AddArg2(v2, v6)
1525 v.AddArg2(v0, v1)
1526 return true
1527 }
1528 }
1529 break
1530 }
1531 return false
1532 }
1533 func RewriteBlock(b *ssa.Block) bool {
1534 return false
1535 }
1536
View as plain text