|
580 | 580 | (sub ty (zero_reg) x)) |
581 | 581 |
|
582 | 582 | ;; `i128` |
583 | | -(rule 2 (lower (has_type $I128 (ineg x))) |
| 583 | +(rule 2 (lower (has_type $I128 (ineg x))) |
584 | 584 | (sub_i128 (value_regs_zero) x)) |
585 | 585 |
|
586 | 586 | ;; vectors. |
|
1054 | 1054 |
|
1055 | 1055 | ;;;; Rules for `band` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1056 | 1056 |
|
1057 | | -(rule -1 (lower (has_type (fits_in_32 ty) (band x y))) |
| 1057 | +(rule -1 (lower (has_type (fits_in_64 ty) (band x y))) |
1058 | 1058 | (alu_rs_imm_logic_commutative (ALUOp.And) ty x y)) |
1059 | 1059 |
|
1060 | | -(rule (lower (has_type $I64 (band x y))) |
1061 | | - (alu_rs_imm_logic_commutative (ALUOp.And) $I64 x y)) |
1062 | | - |
1063 | 1060 | (rule (lower (has_type $I128 (band x y))) (i128_alu_bitop (ALUOp.And) $I64 x y)) |
1064 | 1061 |
|
1065 | 1062 | (rule -2 (lower (has_type (ty_vec128 ty) (band x y))) |
1066 | 1063 | (and_vec x y (vector_size ty))) |
1067 | 1064 |
|
| 1065 | +;; Specialized lowerings for `(band x (bnot y))` which is additionally produced |
| 1066 | +;; by Cranelift's `band_not` instruction that is legalized into the simpler |
| 1067 | +;; forms early on. |
| 1068 | + |
| 1069 | +(rule 1 (lower (has_type (fits_in_64 ty) (band x (bnot y)))) |
| 1070 | + (alu_rs_imm_logic (ALUOp.AndNot) ty x y)) |
| 1071 | +(rule 2 (lower (has_type (fits_in_64 ty) (band (bnot y) x))) |
| 1072 | + (alu_rs_imm_logic (ALUOp.AndNot) ty x y)) |
| 1073 | + |
| 1074 | +(rule 3 (lower (has_type $I128 (band x (bnot y)))) (i128_alu_bitop (ALUOp.AndNot) $I64 x y)) |
| 1075 | +(rule 4 (lower (has_type $I128 (band (bnot y) x))) (i128_alu_bitop (ALUOp.AndNot) $I64 x y)) |
| 1076 | + |
| 1077 | +(rule 5 (lower (has_type (ty_vec128 ty) (band x (bnot y)))) |
| 1078 | + (bic_vec x y (vector_size ty))) |
| 1079 | +(rule 6 (lower (has_type (ty_vec128 ty) (band (bnot y) x))) |
| 1080 | + (bic_vec x y (vector_size ty))) |
| 1081 | + |
1068 | 1082 | ;;;; Rules for `bor` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1069 | 1083 |
|
1070 | | -(rule -1 (lower (has_type (fits_in_32 ty) (bor x y))) |
| 1084 | +(rule -1 (lower (has_type (fits_in_64 ty) (bor x y))) |
1071 | 1085 | (alu_rs_imm_logic_commutative (ALUOp.Orr) ty x y)) |
1072 | 1086 |
|
1073 | | -(rule (lower (has_type $I64 (bor x y))) |
1074 | | - (alu_rs_imm_logic_commutative (ALUOp.Orr) $I64 x y)) |
1075 | | - |
1076 | 1087 | (rule (lower (has_type $I128 (bor x y))) (i128_alu_bitop (ALUOp.Orr) $I64 x y)) |
1077 | 1088 |
|
1078 | 1089 | (rule -2 (lower (has_type (ty_vec128 ty) (bor x y))) |
1079 | 1090 | (orr_vec x y (vector_size ty))) |
1080 | 1091 |
|
| 1092 | +;; Specialized lowerings for `(bor x (bnot y))` which is additionally produced |
| 1093 | +;; by Cranelift's `bor_not` instruction that is legalized into the simpler |
| 1094 | +;; forms early on. |
| 1095 | + |
| 1096 | +(rule 1 (lower (has_type (fits_in_64 ty) (bor x (bnot y)))) |
| 1097 | + (alu_rs_imm_logic (ALUOp.OrrNot) ty x y)) |
| 1098 | +(rule 2 (lower (has_type (fits_in_64 ty) (bor (bnot y) x))) |
| 1099 | + (alu_rs_imm_logic (ALUOp.OrrNot) ty x y)) |
| 1100 | + |
| 1101 | +(rule 3 (lower (has_type $I128 (bor x (bnot y)))) (i128_alu_bitop (ALUOp.OrrNot) $I64 x y)) |
| 1102 | +(rule 4 (lower (has_type $I128 (bor (bnot y) x))) (i128_alu_bitop (ALUOp.OrrNot) $I64 x y)) |
| 1103 | + |
1081 | 1104 | ;;;; Rules for `bxor` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1082 | 1105 |
|
1083 | | -(rule -1 (lower (has_type (fits_in_32 ty) (bxor x y))) |
| 1106 | +(rule -1 (lower (has_type (fits_in_64 ty) (bxor x y))) |
1084 | 1107 | (alu_rs_imm_logic_commutative (ALUOp.Eor) ty x y)) |
1085 | 1108 |
|
1086 | | -(rule (lower (has_type $I64 (bxor x y))) |
1087 | | - (alu_rs_imm_logic_commutative (ALUOp.Eor) $I64 x y)) |
1088 | | - |
1089 | 1109 | (rule (lower (has_type $I128 (bxor x y))) (i128_alu_bitop (ALUOp.Eor) $I64 x y)) |
1090 | 1110 |
|
1091 | 1111 | (rule -2 (lower (has_type (ty_vec128 ty) (bxor x y))) |
1092 | 1112 | (eor_vec x y (vector_size ty))) |
1093 | 1113 |
|
1094 | | -;;;; Rules for `band_not` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1095 | | - |
1096 | | -(rule -1 (lower (has_type (fits_in_32 ty) (band_not x y))) |
1097 | | - (alu_rs_imm_logic (ALUOp.AndNot) ty x y)) |
1098 | | - |
1099 | | -(rule (lower (has_type $I64 (band_not x y))) |
1100 | | - (alu_rs_imm_logic (ALUOp.AndNot) $I64 x y)) |
| 1114 | +;; Specialized lowerings for `(bxor x (bnot y))` which is additionally produced |
| 1115 | +;; by Cranelift's `bxor_not` instruction that is legalized into the simpler |
| 1116 | +;; forms early on. |
1101 | 1117 |
|
1102 | | -(rule (lower (has_type $I128 (band_not x y))) (i128_alu_bitop (ALUOp.AndNot) $I64 x y)) |
| 1118 | +(rule 1 (lower (has_type (fits_in_64 ty) (bxor x (bnot y)))) |
| 1119 | + (alu_rs_imm_logic (ALUOp.EorNot) ty x y)) |
| 1120 | +(rule 2 (lower (has_type (fits_in_64 ty) (bxor (bnot y) x))) |
| 1121 | + (alu_rs_imm_logic (ALUOp.EorNot) ty x y)) |
1103 | 1122 |
|
1104 | | -(rule -2 (lower (has_type (ty_vec128 ty) (band_not x y))) |
1105 | | - (bic_vec x y (vector_size ty))) |
1106 | | - |
1107 | | -;;;; Rules for `bor_not` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1108 | | - |
1109 | | -(rule -1 (lower (has_type (fits_in_32 ty) (bor_not x y))) |
1110 | | - (alu_rs_imm_logic (ALUOp.OrrNot) ty x y)) |
1111 | | - |
1112 | | -(rule (lower (has_type $I64 (bor_not x y))) |
1113 | | - (alu_rs_imm_logic (ALUOp.OrrNot) $I64 x y)) |
1114 | | - |
1115 | | -(rule (lower (has_type $I128 (bor_not x y))) (i128_alu_bitop (ALUOp.OrrNot) $I64 x y)) |
1116 | | - |
1117 | | -;;;; Rules for `bxor_not` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1118 | | - |
1119 | | -(rule -1 (lower (has_type (fits_in_32 ty) (bxor_not x y))) |
1120 | | - (alu_rs_imm_logic (ALUOp.EorNot) $I32 x y)) |
1121 | | - |
1122 | | -(rule (lower (has_type $I64 (bxor_not x y))) |
1123 | | - (alu_rs_imm_logic (ALUOp.EorNot) $I64 x y)) |
1124 | | - |
1125 | | -(rule (lower (has_type $I128 (bxor_not x y))) (i128_alu_bitop (ALUOp.EorNot) $I64 x y)) |
| 1123 | +(rule 3 (lower (has_type $I128 (bxor x (bnot y)))) (i128_alu_bitop (ALUOp.EorNot) $I64 x y)) |
| 1124 | +(rule 4 (lower (has_type $I128 (bxor (bnot y) x))) (i128_alu_bitop (ALUOp.EorNot) $I64 x y)) |
1126 | 1125 |
|
1127 | 1126 | ;;;; Rules for `ishl` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1128 | 1127 |
|
|
2407 | 2406 | ;; sign extended. We then check if the output sign bit has flipped. |
2408 | 2407 | (rule 0 (lower (has_type (fits_in_16 ty) (iadd_cout a b))) |
2409 | 2408 | (let ((extend ExtendOp (lower_extend_op ty $true)) |
2410 | | - |
| 2409 | + |
2411 | 2410 | ;; Instead of emitting two `sxt{b,h}` we do one as an instruction and |
2412 | 2411 | ;; the other as an extend operation in the `add` instruction. |
2413 | 2412 | ;; |
|
2417 | 2416 | ;; cset out_carry, ne |
2418 | 2417 | (a_sext Reg (put_in_reg_sext32 a)) |
2419 | 2418 | (out Reg (add_extend_op ty a_sext b extend)) |
2420 | | - (out_carry Reg (with_flags_reg |
| 2419 | + (out_carry Reg (with_flags_reg |
2421 | 2420 | (cmp_extend (OperandSize.Size32) out out extend) |
2422 | 2421 | (cset (Cond.Ne))))) |
2423 | 2422 | (output_pair |
|
0 commit comments