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