|
14 | 14 | (decl lower_cond (Value) Cond)
|
15 | 15 | (rule 0 (lower_cond val @ (value_type (fits_in_32 _))) (Cond.If32 (zext32 val)))
|
16 | 16 | (rule 1 (lower_cond val @ (value_type $I64))
|
17 |
| - (Cond.IfXneq64 val (pulley_xconst8 0))) |
| 17 | + (Cond.IfXneq64I32 val 0)) |
18 | 18 |
|
19 | 19 | ;; Peel away explicit `uextend` values to take a look at the inner value.
|
20 | 20 | (rule 2 (lower_cond (uextend val)) (lower_cond val))
|
|
282 | 282 | ;;;; Rules for `umulhi` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
283 | 283 |
|
284 | 284 | (rule (lower (has_type $I8 (umulhi a b)))
|
285 |
| - (pulley_xshr32_u (pulley_xmul32 (zext32 a) (zext32 b)) (pulley_xconst8 8))) |
| 285 | + (if-let (u6_from_u8 shift) (u64_as_u8 8)) |
| 286 | + (pulley_xshr32_u_u6 (pulley_xmul32 (zext32 a) (zext32 b)) shift)) |
286 | 287 |
|
287 | 288 | (rule (lower (has_type $I16 (umulhi a b)))
|
288 |
| - (pulley_xshr32_u (pulley_xmul32 (zext32 a) (zext32 b)) (pulley_xconst8 16))) |
| 289 | + (if-let (u6_from_u8 shift) (u64_as_u8 16)) |
| 290 | + (pulley_xshr32_u_u6 (pulley_xmul32 (zext32 a) (zext32 b)) shift)) |
289 | 291 |
|
290 | 292 | (rule (lower (has_type $I32 (umulhi a b)))
|
291 |
| - (pulley_xshr64_u (pulley_xmul64 (zext64 a) (zext64 b)) (pulley_xconst8 32))) |
| 293 | + (if-let (u6_from_u8 shift) (u64_as_u8 32)) |
| 294 | + (pulley_xshr64_u_u6 (pulley_xmul64 (zext64 a) (zext64 b)) shift)) |
292 | 295 |
|
293 | 296 | (rule (lower (has_type $I64 (umulhi a b)))
|
294 | 297 | (pulley_xmulhi64_u a b))
|
295 | 298 |
|
296 | 299 | ;;;; Rules for `smulhi` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
297 | 300 |
|
298 | 301 | (rule (lower (has_type $I8 (smulhi a b)))
|
299 |
| - (pulley_xshr32_s (pulley_xmul32 (sext32 a) (sext32 b)) (pulley_xconst8 8))) |
| 302 | + (if-let (u6_from_u8 shift) (u64_as_u8 8)) |
| 303 | + (pulley_xshr32_s_u6 (pulley_xmul32 (sext32 a) (sext32 b)) shift)) |
300 | 304 |
|
301 | 305 | (rule (lower (has_type $I16 (smulhi a b)))
|
302 |
| - (pulley_xshr32_s (pulley_xmul32 (sext32 a) (sext32 b)) (pulley_xconst8 16))) |
| 306 | + (if-let (u6_from_u8 shift) (u64_as_u8 16)) |
| 307 | + (pulley_xshr32_s_u6 (pulley_xmul32 (sext32 a) (sext32 b)) shift)) |
303 | 308 |
|
304 | 309 | (rule (lower (has_type $I32 (smulhi a b)))
|
305 |
| - (pulley_xshr64_s (pulley_xmul64 (sext64 a) (sext64 b)) (pulley_xconst8 32))) |
| 310 | + (if-let (u6_from_u8 shift) (u64_as_u8 32)) |
| 311 | + (pulley_xshr64_s_u6 (pulley_xmul64 (sext64 a) (sext64 b)) shift)) |
306 | 312 |
|
307 | 313 | (rule (lower (has_type $I64 (smulhi a b)))
|
308 | 314 | (pulley_xmulhi64_s a b))
|
|
334 | 340 | ;;;; Rules for `ishl` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
335 | 341 |
|
336 | 342 | (rule (lower (has_type $I8 (ishl a b)))
|
337 |
| - (pulley_xshl32 a (pulley_xband32 b (pulley_xconst8 7)))) |
| 343 | + (pulley_xshl32 a (pulley_xband32_s8 b 7))) |
338 | 344 |
|
339 | 345 | (rule (lower (has_type $I16 (ishl a b)))
|
340 |
| - (pulley_xshl32 a (pulley_xband32 b (pulley_xconst8 15)))) |
| 346 | + (pulley_xshl32 a (pulley_xband32_s8 b 15))) |
341 | 347 |
|
342 | 348 | (rule (lower (has_type $I32 (ishl a b)))
|
343 | 349 | (pulley_xshl32 a b))
|
|
373 | 379 | ;;;; Rules for `ushr` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
374 | 380 |
|
375 | 381 | (rule (lower (has_type $I8 (ushr a b)))
|
376 |
| - (pulley_xshr32_u (zext32 a) (pulley_xband32 b (pulley_xconst8 7)))) |
| 382 | + (pulley_xshr32_u (zext32 a) (pulley_xband32_s8 b 7))) |
377 | 383 |
|
378 | 384 | (rule (lower (has_type $I16 (ushr a b)))
|
379 |
| - (pulley_xshr32_u (zext32 a) (pulley_xband32 b (pulley_xconst8 15)))) |
| 385 | + (pulley_xshr32_u (zext32 a) (pulley_xband32_s8 b 15))) |
380 | 386 |
|
381 | 387 | (rule (lower (has_type $I32 (ushr a b)))
|
382 | 388 | (pulley_xshr32_u a b))
|
|
402 | 408 | ;;;; Rules for `sshr` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
403 | 409 |
|
404 | 410 | (rule (lower (has_type $I8 (sshr a b)))
|
405 |
| - (pulley_xshr32_u (sext32 a) (pulley_xband32 b (pulley_xconst8 7)))) |
| 411 | + (pulley_xshr32_u (sext32 a) (pulley_xband32_s8 b 7))) |
406 | 412 |
|
407 | 413 | (rule (lower (has_type $I16 (sshr a b)))
|
408 |
| - (pulley_xshr32_u (sext32 a) (pulley_xband32 b (pulley_xconst8 15)))) |
| 414 | + (pulley_xshr32_u (sext32 a) (pulley_xband32_s8 b 15))) |
409 | 415 |
|
410 | 416 | (rule (lower (has_type $I32 (sshr a b)))
|
411 | 417 | (pulley_xshr32_s a b))
|
|
531 | 537 | ;;;; Rules for `ctz` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
532 | 538 |
|
533 | 539 | (rule (lower (has_type $I8 (ctz a)))
|
534 |
| - (pulley_xctz32 (pulley_xbor32 a (pulley_xconst16 0x100)))) |
| 540 | + (pulley_xctz32 (pulley_xbor32_s32 a 0x100))) |
535 | 541 | (rule (lower (has_type $I16 (ctz a)))
|
536 |
| - (pulley_xctz32 (pulley_xbor32 a (pulley_xconst32 0x10000)))) |
| 542 | + (pulley_xctz32 (pulley_xbor32_s32 a 0x10000))) |
537 | 543 | (rule (lower (has_type $I32 (ctz a))) (pulley_xctz32 a))
|
538 | 544 | (rule (lower (has_type $I64 (ctz a))) (pulley_xctz64 a))
|
539 | 545 |
|
540 | 546 | ;;;; Rules for `clz` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
541 | 547 |
|
542 | 548 | (rule (lower (has_type $I8 (clz a)))
|
543 |
| - (pulley_xsub32 (pulley_xclz32 (zext32 a)) (pulley_xconst8 24))) |
| 549 | + (pulley_xsub32_u8 (pulley_xclz32 (zext32 a)) 24)) |
544 | 550 | (rule (lower (has_type $I16 (clz a)))
|
545 |
| - (pulley_xsub32 (pulley_xclz32 (zext32 a)) (pulley_xconst8 16))) |
| 551 | + (pulley_xsub32_u8 (pulley_xclz32 (zext32 a)) 16)) |
546 | 552 | (rule (lower (has_type $I32 (clz a))) (pulley_xclz32 a))
|
547 | 553 | (rule (lower (has_type $I64 (clz a))) (pulley_xclz64 a))
|
548 | 554 |
|
|
641 | 647 |
|
642 | 648 | ;; complement `=`-related conditions to get ones that don't use `=`.
|
643 | 649 | (rule 2 (lower_icmp $I128 cc @ (IntCC.SignedLessThanOrEqual) x y)
|
644 |
| - (pulley_xbxor32 (lower_icmp $I128 (intcc_complement cc) x y) (pulley_xconst8 1))) |
| 650 | + (pulley_xbxor32_s8 (lower_icmp $I128 (intcc_complement cc) x y) 1)) |
645 | 651 | (rule 2 (lower_icmp $I128 cc @ (IntCC.SignedGreaterThanOrEqual) x y)
|
646 |
| - (pulley_xbxor32 (lower_icmp $I128 (intcc_complement cc) x y) (pulley_xconst8 1))) |
| 652 | + (pulley_xbxor32_s8 (lower_icmp $I128 (intcc_complement cc) x y) 1)) |
647 | 653 | (rule 2 (lower_icmp $I128 cc @ (IntCC.UnsignedLessThanOrEqual) x y)
|
648 |
| - (pulley_xbxor32 (lower_icmp $I128 (intcc_complement cc) x y) (pulley_xconst8 1))) |
| 654 | + (pulley_xbxor32_s8 (lower_icmp $I128 (intcc_complement cc) x y) 1)) |
649 | 655 | (rule 2 (lower_icmp $I128 cc @ (IntCC.UnsignedGreaterThanOrEqual) x y)
|
650 |
| - (pulley_xbxor32 (lower_icmp $I128 (intcc_complement cc) x y) (pulley_xconst8 1))) |
| 656 | + (pulley_xbxor32_s8 (lower_icmp $I128 (intcc_complement cc) x y) 1)) |
651 | 657 |
|
652 | 658 | ;; Compare both the bottom and upper halves of the 128-bit values. If
|
653 | 659 | ;; the top half is equal use the bottom comparison, otherwise use the upper
|
|
872 | 878 | (sext64 val))
|
873 | 879 |
|
874 | 880 | (rule 1 (lower (has_type $I128 (sextend val)))
|
| 881 | + (if-let (u6_from_u8 shift) (u64_as_u8 63)) |
875 | 882 | (let ((lo XReg (sext64 val))
|
876 |
| - (hi XReg (pulley_xshr64_s lo (pulley_xconst8 63)))) |
| 883 | + (hi XReg (pulley_xshr64_s_u6 lo shift))) |
877 | 884 | (value_regs lo hi)))
|
878 | 885 |
|
879 | 886 | ;;;; Rules for `ireduce` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1197 | 1204 | ;;;; Rules for `bswap` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
1198 | 1205 |
|
1199 | 1206 | (rule (lower (has_type $I16 (bswap a)))
|
1200 |
| - (pulley_xshr32_u (pulley_bswap32 a) (pulley_xconst8 16))) |
| 1207 | + (if-let (u6_from_u8 shift) (u64_as_u8 16)) |
| 1208 | + (pulley_xshr32_u_u6 (pulley_bswap32 a) shift)) |
1201 | 1209 | (rule (lower (has_type $I32 (bswap a))) (pulley_bswap32 a))
|
1202 | 1210 | (rule (lower (has_type $I64 (bswap a))) (pulley_bswap64 a))
|
1203 | 1211 |
|
|
0 commit comments