;; vect__13.182_33 = .FMA (vect__11.180_35, vect__8.176_40, vect__4.172_45);
(define_insn_and_split "*double_widen_fma<mode>"
[(set (match_operand:VWEXTF 0 "register_operand")
- (fma:VWEXTF
- (float_extend:VWEXTF
- (match_operand:<V_DOUBLE_TRUNC> 2 "register_operand"))
- (float_extend:VWEXTF
- (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand"))
- (match_operand:VWEXTF 1 "register_operand")))]
+ (unspec:VWEXTF
+ [(fma:VWEXTF
+ (float_extend:VWEXTF
+ (match_operand:<V_DOUBLE_TRUNC> 2 "register_operand"))
+ (float_extend:VWEXTF
+ (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand"))
+ (match_operand:VWEXTF 1 "register_operand"))
+ (reg:SI FRM_REGNUM)] UNSPEC_VFFMA))]
"TARGET_VECTOR && can_create_pseudo_p ()"
"#"
"&& 1"
DONE;
}
[(set_attr "type" "vfwmuladd")
- (set_attr "mode" "<V_DOUBLE_TRUNC>")])
+ (set_attr "mode" "<V_DOUBLE_TRUNC>")
+ (set (attr "frm_mode") (symbol_ref "riscv_vector::FRM_DYN"))])
;; This helps to match ext + fma.
(define_insn_and_split "*single_widen_fma<mode>"
[(set (match_operand:VWEXTF 0 "register_operand")
- (fma:VWEXTF
- (float_extend:VWEXTF
- (match_operand:<V_DOUBLE_TRUNC> 2 "register_operand"))
- (match_operand:VWEXTF 3 "register_operand")
- (match_operand:VWEXTF 1 "register_operand")))]
+ (unspec:VWEXTF
+ [(fma:VWEXTF
+ (float_extend:VWEXTF
+ (match_operand:<V_DOUBLE_TRUNC> 2 "register_operand"))
+ (match_operand:VWEXTF 3 "register_operand")
+ (match_operand:VWEXTF 1 "register_operand"))
+ (reg:SI FRM_REGNUM)] UNSPEC_VFFMA))]
"TARGET_VECTOR && can_create_pseudo_p ()"
"#"
"&& 1"
DONE;
}
[(set_attr "type" "vfwmuladd")
- (set_attr "mode" "<V_DOUBLE_TRUNC>")])
+ (set_attr "mode" "<V_DOUBLE_TRUNC>")
+ (set (attr "frm_mode") (symbol_ref "riscv_vector::FRM_DYN"))])
;; -------------------------------------------------------------------------
;; ---- [FP] VFWNMSAC
(define_expand "fma<mode>4"
[(parallel
[(set (match_operand:VF 0 "register_operand")
- (fma:VF
- (match_operand:VF 1 "register_operand")
- (match_operand:VF 2 "register_operand")
- (match_operand:VF 3 "register_operand")))
+ (unspec:VF
+ [(fma:VF
+ (match_operand:VF 1 "register_operand")
+ (match_operand:VF 2 "register_operand")
+ (match_operand:VF 3 "register_operand"))
+ (reg:SI FRM_REGNUM)] UNSPEC_VFFMA))
(clobber (match_dup 4))])]
"TARGET_VECTOR"
{
operands[4] = gen_reg_rtx (Pmode);
- })
+ }
+ [(set (attr "frm_mode") (symbol_ref "riscv_vector::FRM_DYN"))])
(define_insn_and_split "*fma<VF:mode><P:mode>"
[(set (match_operand:VF 0 "register_operand" "=vr, vr, ?&vr")
- (fma:VF
- (match_operand:VF 1 "register_operand" " %0, vr, vr")
- (match_operand:VF 2 "register_operand" " vr, vr, vr")
- (match_operand:VF 3 "register_operand" " vr, 0, vr")))
+ (unspec:VF
+ [(fma:VF
+ (match_operand:VF 1 "register_operand" " %0, vr, vr")
+ (match_operand:VF 2 "register_operand" " vr, vr, vr")
+ (match_operand:VF 3 "register_operand" " vr, 0, vr"))
+ (reg:SI FRM_REGNUM)] UNSPEC_VFFMA))
(clobber (match_operand:P 4 "register_operand" "=r,r,r"))]
"TARGET_VECTOR"
"#"
DONE;
}
[(set_attr "type" "vfmuladd")
- (set_attr "mode" "<VF:MODE>")])
+ (set_attr "mode" "<VF:MODE>")
+ (set (attr "frm_mode") (symbol_ref "riscv_vector::FRM_DYN"))])
;; -------------------------------------------------------------------------
;; ---- [FP] VFNMSAC and VFNMSUB
UNSPEC_VCOMPRESS
UNSPEC_VLEFF
UNSPEC_MODIFY_VL
+
+ UNSPEC_VFFMA
])
(define_c_enum "unspecv" [
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv --param=riscv-autovec-preference=fixed-vlmax -ffast-math -mabi=lp64 -O3 -Wno-psabi" } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+#include "riscv_vector.h"
+
+/*
+**test_1:
+** ...
+** frrm\t[axt][0-9]+
+** ...
+** fsrmi\t1
+** ...
+** vfsub\.vv\tv[0-9]+,v[0-9]+,v[0-9]+
+** ...
+** fsrm\t[axt][0-9]+
+** ...
+** vfmadd\.vv\tv[0-9]+,v[0-9]+,v[0-9]+
+** ...
+** ret
+*/
+void
+test_1 (vfloat32m1_t op1, vfloat32m1_t op2, vfloat32m1_t *op_out, size_t vl,
+ double *in1, double *in2, double *out)
+{
+ *op_out = __riscv_vfsub_vv_f32m1_rm (op1, op2, 1, vl);
+
+ for (int i = 0; i < 4; ++i)
+ out[i] += in1[i] * in2[i];
+}
+
+/*
+**test_2:
+** ...
+** frrm\t[axt][0-9]+
+** ...
+** fsrmi\t1
+** ...
+** vfsub\.vv\tv[0-9]+,v[0-9]+,v[0-9]+
+** ...
+** fsrm\t[axt][0-9]+
+** ...
+** vfmadd\.vv\tv[0-9]+,v[0-9]+,v[0-9]+
+** ...
+** fsrmi\t4
+** ...
+** vfsub\.vv\tv[0-9]+,v[0-9]+,v[0-9]+
+** ...
+** fsrm\t[axt][0-9]+
+** ...
+** ret
+*/
+void
+test_2 (vfloat32m1_t op1, vfloat32m1_t op2, vfloat32m1_t *op_out, size_t vl,
+ double *in1, double *in2, double *out)
+{
+ op2 = __riscv_vfsub_vv_f32m1_rm (op1, op2, 1, vl);
+
+ for (int i = 0; i < 4; ++i)
+ out[i] = out[i] * in1[i] + in2[i];
+
+ *op_out = __riscv_vfsub_vv_f32m1_rm (op1, op2, 4, vl);
+}
+
+/*
+**test_3:
+** ...
+** frrm\t[axt][0-9]+
+** ...
+** vfmadd\.vv\tv[0-9]+,v[0-9]+,v[0-9]+
+** ...
+** fsrmi\t4
+** ...
+** vfsub\.vv\tv[0-9]+,v[0-9]+,v[0-9]+
+** ...
+** fsrm\t[axt][0-9]+
+** ...
+** ret
+*/
+void
+test_3 (vfloat32m1_t op1, vfloat32m1_t op2, vfloat32m1_t *op_out, size_t vl,
+ double *in1, double *in2, double *in3, double *out)
+{
+ for (int i = 0; i < 4; ++i)
+ out[i] = in1[i] + in2[i] * out[i];
+
+ *op_out = __riscv_vfsub_vv_f32m1_rm (op1, op2, 4, vl);
+}