|
1351 | 1351 | ;; Note that bitwise negation is implemented here as |
1352 | 1352 | ;; |
1353 | 1353 | ;; NOT rd, rm ==> ORR_NOT rd, zero, rm |
1354 | | -(rule bnot_base_case -3 (lower (has_type (fits_in_64 ty) (bnot x))) |
| 1354 | +(rule bnot_base_case -4 (lower (has_type (fits_in_64 (ty_int ty)) (bnot x))) |
1355 | 1355 | (orr_not ty (zero_reg) x)) |
1356 | 1356 |
|
| 1357 | +;; Implementation of `bnot` for floats. |
| 1358 | +(rule -3 (lower (has_type (fits_in_64 (ty_scalar_float ty)) (bnot x))) |
| 1359 | + (not x (float_vector_size_in_64 ty))) |
| 1360 | + |
1357 | 1361 | ;; Implementation of `bnot` for vector types. |
1358 | | -(rule -2 (lower (has_type (ty_vec64 ty) (bnot x))) |
| 1362 | +(rule -2 (lower (has_type (ty_vec64 ty) (bnot x))) |
1359 | 1363 | (not x (vector_size ty))) |
1360 | | -(rule -1 (lower (has_type (ty_vec128 ty) (bnot x))) |
| 1364 | +(rule -1 (lower (has_type (ty_vec128 ty) (bnot x))) |
1361 | 1365 | (not x (vector_size ty))) |
1362 | 1366 |
|
1363 | 1367 | ;; Implementation of `bnot` for `i128`. |
|
1371 | 1375 |
|
1372 | 1376 | ;; Special case to use `orr_not_shift` if it's a `bnot` of a const-left-shifted |
1373 | 1377 | ;; value. |
1374 | | -(rule bnot_ishl 1 (lower (has_type (fits_in_64 ty) |
| 1378 | +(rule bnot_ishl 1 (lower (has_type (fits_in_64 (ty_int ty)) |
1375 | 1379 | (bnot (ishl x (iconst k))))) |
1376 | 1380 | (if-let amt (lshl_from_imm64 ty k)) |
1377 | 1381 | (orr_not_shift ty (zero_reg) x amt)) |
|
1383 | 1387 |
|
1384 | 1388 | ;;;; Rules for `band` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1385 | 1389 |
|
1386 | | -(rule band_fits_in_64 -4 (lower (has_type (fits_in_64 (ty_int ty)) (band x y))) |
| 1390 | +(rule band_fits_in_64 -5 (lower (has_type (fits_in_64 (ty_int ty)) (band x y))) |
1387 | 1391 | (alu_rs_imm_logic_commutative (ALUOp.And) ty x y)) |
1388 | 1392 |
|
1389 | | -(rule -3 (lower (has_type (fits_in_64 (ty_scalar_float ty)) (band x y))) |
| 1393 | +(rule -4 (lower (has_type (fits_in_64 (ty_scalar_float ty)) (band x y))) |
1390 | 1394 | (and_vec x y (float_vector_size_in_64 ty))) |
1391 | 1395 |
|
1392 | 1396 | ;; Implementation of `band` for vector types. |
1393 | | -(rule -2 (lower (has_type (ty_vec64 ty) (band x y))) |
| 1397 | +(rule -2 (lower (has_type (ty_vec64 ty) (band x y))) |
1394 | 1398 | (and_vec x y (vector_size ty))) |
1395 | | -(rule -1 (lower (has_type (ty_vec128 ty) (band x y))) |
| 1399 | +(rule -1 (lower (has_type (ty_vec128 ty) (band x y))) |
1396 | 1400 | (and_vec x y (vector_size ty))) |
1397 | 1401 |
|
1398 | 1402 | (rule (lower (has_type $I128 (band x y))) (i128_alu_bitop (ALUOp.And) $I64 x y)) |
1399 | 1403 |
|
1400 | 1404 | ;; Specialized lowerings for `(band x (bnot y))` which is additionally produced |
1401 | 1405 | ;; by Cranelift's `band_not` instruction that is legalized into the simpler |
1402 | 1406 | ;; forms early on. |
1403 | | -(rule band_not_right 1 (lower (has_type (fits_in_64 ty) (band x (bnot y)))) |
| 1407 | +(rule band_not_right 1 (lower (has_type (fits_in_64 (ty_int ty)) (band x (bnot y)))) |
1404 | 1408 | (alu_rs_imm_logic (ALUOp.AndNot) ty x y)) |
1405 | | -(rule band_not_left 2 (lower (has_type (fits_in_64 ty) (band (bnot y) x))) |
| 1409 | +(rule band_not_left 2 (lower (has_type (fits_in_64 (ty_int ty)) (band (bnot y) x))) |
1406 | 1410 | (alu_rs_imm_logic (ALUOp.AndNot) ty x y)) |
1407 | 1411 |
|
1408 | 1412 | (rule 3 (lower (has_type $I128 (band x (bnot y)))) (i128_alu_bitop (ALUOp.AndNot) $I64 x y)) |
|
1427 | 1431 | (orr_vec x y (float_vector_size_in_64 ty))) |
1428 | 1432 |
|
1429 | 1433 | ;; Implementation of `bor` for vector types. |
1430 | | -(rule -2 (lower (has_type (ty_vec64 ty) (bor x y))) |
| 1434 | +(rule -2 (lower (has_type (ty_vec64 ty) (bor x y))) |
1431 | 1435 | (orr_vec x y (vector_size ty))) |
1432 | | -(rule -1 (lower (has_type (ty_vec128 ty) (bor x y))) |
| 1436 | +(rule -1 (lower (has_type (ty_vec128 ty) (bor x y))) |
1433 | 1437 | (orr_vec x y (vector_size ty))) |
1434 | 1438 |
|
1435 | 1439 | (rule (lower (has_type $I128 (bor x y))) (i128_alu_bitop (ALUOp.Orr) $I64 x y)) |
1436 | 1440 |
|
1437 | 1441 | ;; Specialized lowerings for `(bor x (bnot y))` which is additionally produced |
1438 | 1442 | ;; by Cranelift's `bor_not` instruction that is legalized into the simpler |
1439 | 1443 | ;; forms early on. |
1440 | | -(rule bor_not_right 1 (lower (has_type (fits_in_64 ty) (bor x (bnot y)))) |
| 1444 | +(rule bor_not_right 1 (lower (has_type (fits_in_64 (ty_int ty)) (bor x (bnot y)))) |
1441 | 1445 | (alu_rs_imm_logic (ALUOp.OrrNot) ty x y)) |
1442 | | -(rule bor_not_left 2 (lower (has_type (fits_in_64 ty) (bor (bnot y) x))) |
| 1446 | +(rule bor_not_left 2 (lower (has_type (fits_in_64 (ty_int ty)) (bor (bnot y) x))) |
1443 | 1447 | (alu_rs_imm_logic (ALUOp.OrrNot) ty x y)) |
1444 | 1448 |
|
1445 | 1449 | (rule 3 (lower (has_type $I128 (bor x (bnot y)))) (i128_alu_bitop (ALUOp.OrrNot) $I64 x y)) |
1446 | 1450 | (rule 4 (lower (has_type $I128 (bor (bnot y) x))) (i128_alu_bitop (ALUOp.OrrNot) $I64 x y)) |
1447 | 1451 |
|
1448 | | -(rule bor_not_right_vec64 5 (lower (has_type (ty_vec64 ty) (bor x (bnot y)))) |
| 1452 | +(rule bor_not_right_vec64 5 (lower (has_type (ty_vec64 ty) (bor x (bnot y)))) |
1449 | 1453 | (orn_vec x y (vector_size ty))) |
1450 | | -(rule bor_not_left_vec64 6 (lower (has_type (ty_vec64 ty) (bor (bnot y) x))) |
| 1454 | +(rule bor_not_left_vec64 6 (lower (has_type (ty_vec64 ty) (bor (bnot y) x))) |
1451 | 1455 | (orn_vec x y (vector_size ty))) |
1452 | 1456 |
|
1453 | | -(rule bor_not_right_vec128 7 (lower (has_type (ty_vec128 ty) (bor x (bnot y)))) |
| 1457 | +(rule bor_not_right_vec128 7 (lower (has_type (ty_vec128 ty) (bor x (bnot y)))) |
1454 | 1458 | (orn_vec x y (vector_size ty))) |
1455 | | -(rule bor_not_left_vec128 8 (lower (has_type (ty_vec128 ty) (bor (bnot y) x))) |
| 1459 | +(rule bor_not_left_vec128 8 (lower (has_type (ty_vec128 ty) (bor (bnot y) x))) |
1456 | 1460 | (orn_vec x y (vector_size ty))) |
1457 | 1461 |
|
1458 | 1462 |
|
|
1481 | 1485 | (rule bxor_fits_in_64 -4 (lower (has_type (fits_in_64 (ty_int ty)) (bxor x y))) |
1482 | 1486 | (alu_rs_imm_logic_commutative (ALUOp.Eor) ty x y)) |
1483 | 1487 |
|
1484 | | -(rule -3 (lower (has_type (fits_in_64 (ty_scalar_float ty)) (bxor x y))) |
| 1488 | +(rule -3 (lower (has_type (fits_in_64 (ty_scalar_float ty)) (bxor x y))) |
1485 | 1489 | (eor_vec x y (float_vector_size_in_64 ty))) |
1486 | 1490 |
|
1487 | 1491 | ;; Implementation of `bxor` for vector types. |
1488 | | -(rule -2 (lower (has_type (ty_vec64 ty) (bxor x y))) |
| 1492 | +(rule -2 (lower (has_type (ty_vec64 ty) (bxor x y))) |
1489 | 1493 | (eor_vec x y (vector_size ty))) |
1490 | | -(rule -1 (lower (has_type (ty_vec128 ty) (bxor x y))) |
| 1494 | +(rule -1 (lower (has_type (ty_vec128 ty) (bxor x y))) |
1491 | 1495 | (eor_vec x y (vector_size ty))) |
1492 | 1496 |
|
1493 | 1497 | (rule (lower (has_type $I128 (bxor x y))) (i128_alu_bitop (ALUOp.Eor) $I64 x y)) |
|
1496 | 1500 | ;; by Cranelift's `bxor_not` instruction that is legalized into the simpler |
1497 | 1501 | ;; forms early on. |
1498 | 1502 |
|
1499 | | -(rule bxor_not_right 1 (lower (has_type (fits_in_64 ty) (bxor x (bnot y)))) |
| 1503 | +(rule bxor_not_right 1 (lower (has_type (fits_in_64 (ty_int ty)) (bxor x (bnot y)))) |
1500 | 1504 | (alu_rs_imm_logic (ALUOp.EorNot) ty x y)) |
1501 | | -(rule bxor_not_left 2 (lower (has_type (fits_in_64 ty) (bxor (bnot y) x))) |
| 1505 | +(rule bxor_not_left 2 (lower (has_type (fits_in_64 (ty_int ty)) (bxor (bnot y) x))) |
1502 | 1506 | (alu_rs_imm_logic (ALUOp.EorNot) ty x y)) |
1503 | 1507 |
|
1504 | 1508 | (rule 3 (lower (has_type $I128 (bxor x (bnot y)))) (i128_alu_bitop (ALUOp.EorNot) $I64 x y)) |
|
0 commit comments