@@ -4724,7 +4724,7 @@ defm FCVTZS : FPToIntegerScaled<0b11, 0b000, "fcvtzs", any_fp_to_sint>;
4724
4724
defm FCVTZU : FPToIntegerScaled<0b11, 0b001, "fcvtzu", any_fp_to_uint>;
4725
4725
4726
4726
// AArch64's FCVT instructions saturate when out of range.
4727
- multiclass FPToIntegerSatPats<SDNode to_int_sat, string INST> {
4727
+ multiclass FPToIntegerSatPats<SDNode to_int_sat, SDNode to_int_sat_gi, string INST> {
4728
4728
let Predicates = [HasFullFP16] in {
4729
4729
def : Pat<(i32 (to_int_sat f16:$Rn, i32)),
4730
4730
(!cast<Instruction>(INST # UWHr) f16:$Rn)>;
@@ -4740,6 +4740,21 @@ multiclass FPToIntegerSatPats<SDNode to_int_sat, string INST> {
4740
4740
def : Pat<(i64 (to_int_sat f64:$Rn, i64)),
4741
4741
(!cast<Instruction>(INST # UXDr) f64:$Rn)>;
4742
4742
4743
+ let Predicates = [HasFullFP16] in {
4744
+ def : Pat<(i32 (to_int_sat_gi f16:$Rn)),
4745
+ (!cast<Instruction>(INST # UWHr) f16:$Rn)>;
4746
+ def : Pat<(i64 (to_int_sat_gi f16:$Rn)),
4747
+ (!cast<Instruction>(INST # UXHr) f16:$Rn)>;
4748
+ }
4749
+ def : Pat<(i32 (to_int_sat_gi f32:$Rn)),
4750
+ (!cast<Instruction>(INST # UWSr) f32:$Rn)>;
4751
+ def : Pat<(i64 (to_int_sat_gi f32:$Rn)),
4752
+ (!cast<Instruction>(INST # UXSr) f32:$Rn)>;
4753
+ def : Pat<(i32 (to_int_sat_gi f64:$Rn)),
4754
+ (!cast<Instruction>(INST # UWDr) f64:$Rn)>;
4755
+ def : Pat<(i64 (to_int_sat_gi f64:$Rn)),
4756
+ (!cast<Instruction>(INST # UXDr) f64:$Rn)>;
4757
+
4743
4758
let Predicates = [HasFullFP16] in {
4744
4759
def : Pat<(i32 (to_int_sat (fmul f16:$Rn, fixedpoint_f16_i32:$scale), i32)),
4745
4760
(!cast<Instruction>(INST # SWHri) $Rn, $scale)>;
@@ -4754,10 +4769,25 @@ multiclass FPToIntegerSatPats<SDNode to_int_sat, string INST> {
4754
4769
(!cast<Instruction>(INST # SWDri) $Rn, $scale)>;
4755
4770
def : Pat<(i64 (to_int_sat (fmul f64:$Rn, fixedpoint_f64_i64:$scale), i64)),
4756
4771
(!cast<Instruction>(INST # SXDri) $Rn, $scale)>;
4772
+
4773
+ let Predicates = [HasFullFP16] in {
4774
+ def : Pat<(i32 (to_int_sat_gi (fmul f16:$Rn, fixedpoint_f16_i32:$scale))),
4775
+ (!cast<Instruction>(INST # SWHri) $Rn, $scale)>;
4776
+ def : Pat<(i64 (to_int_sat_gi (fmul f16:$Rn, fixedpoint_f16_i64:$scale))),
4777
+ (!cast<Instruction>(INST # SXHri) $Rn, $scale)>;
4778
+ }
4779
+ def : Pat<(i32 (to_int_sat_gi (fmul f32:$Rn, fixedpoint_f32_i32:$scale))),
4780
+ (!cast<Instruction>(INST # SWSri) $Rn, $scale)>;
4781
+ def : Pat<(i64 (to_int_sat_gi (fmul f32:$Rn, fixedpoint_f32_i64:$scale))),
4782
+ (!cast<Instruction>(INST # SXSri) $Rn, $scale)>;
4783
+ def : Pat<(i32 (to_int_sat_gi (fmul f64:$Rn, fixedpoint_f64_i32:$scale))),
4784
+ (!cast<Instruction>(INST # SWDri) $Rn, $scale)>;
4785
+ def : Pat<(i64 (to_int_sat_gi (fmul f64:$Rn, fixedpoint_f64_i64:$scale))),
4786
+ (!cast<Instruction>(INST # SXDri) $Rn, $scale)>;
4757
4787
}
4758
4788
4759
- defm : FPToIntegerSatPats<fp_to_sint_sat, "FCVTZS">;
4760
- defm : FPToIntegerSatPats<fp_to_uint_sat, "FCVTZU">;
4789
+ defm : FPToIntegerSatPats<fp_to_sint_sat, fp_to_sint_sat_gi, "FCVTZS">;
4790
+ defm : FPToIntegerSatPats<fp_to_uint_sat, fp_to_uint_sat_gi, "FCVTZU">;
4761
4791
4762
4792
multiclass FPToIntegerIntPats<Intrinsic round, string INST> {
4763
4793
let Predicates = [HasFullFP16] in {
0 commit comments