@@ -2779,6 +2779,40 @@ (define_expand "ustrunc<mode><v_oct_trunc>2"
}
)
+(define_expand "sstrunc<mode><v_double_trunc>2"
+ [(match_operand:<V_DOUBLE_TRUNC> 0 "register_operand")
+ (match_operand:VWEXTI 1 "register_operand")]
+ "TARGET_VECTOR"
+ {
+ riscv_vector::expand_vec_double_sstrunc (operands[0], operands[1],
+ <MODE>mode);
+ DONE;
+ }
+)
+
+(define_expand "sstrunc<mode><v_quad_trunc>2"
+ [(match_operand:<V_QUAD_TRUNC> 0 "register_operand")
+ (match_operand:VQEXTI 1 "register_operand")]
+ "TARGET_VECTOR"
+ {
+ riscv_vector::expand_vec_quad_sstrunc (operands[0], operands[1], <MODE>mode,
+ <V_DOUBLE_TRUNC>mode);
+ DONE;
+ }
+)
+
+(define_expand "sstrunc<mode><v_oct_trunc>2"
+ [(match_operand:<V_OCT_TRUNC> 0 "register_operand")
+ (match_operand:VOEXTI 1 "register_operand")]
+ "TARGET_VECTOR"
+ {
+ riscv_vector::expand_vec_oct_sstrunc (operands[0], operands[1], <MODE>mode,
+ <V_DOUBLE_TRUNC>mode,
+ <V_QUAD_TRUNC>mode);
+ DONE;
+ }
+)
+
;; =========================================================================
;; == Early break auto-vectorization patterns
;; =========================================================================
@@ -651,9 +651,13 @@ void expand_vec_ssadd (rtx, rtx, rtx, machine_mode);
void expand_vec_ussub (rtx, rtx, rtx, machine_mode);
void expand_vec_sssub (rtx, rtx, rtx, machine_mode);
void expand_vec_double_ustrunc (rtx, rtx, machine_mode);
+void expand_vec_double_sstrunc (rtx, rtx, machine_mode);
void expand_vec_quad_ustrunc (rtx, rtx, machine_mode, machine_mode);
+void expand_vec_quad_sstrunc (rtx, rtx, machine_mode, machine_mode);
void expand_vec_oct_ustrunc (rtx, rtx, machine_mode, machine_mode,
machine_mode);
+void expand_vec_oct_sstrunc (rtx, rtx, machine_mode, machine_mode,
+ machine_mode);
#endif
bool sew64_scalar_helper (rtx *, rtx *, rtx, machine_mode,
bool, void (*)(rtx *, rtx), enum avl_type);
@@ -4927,6 +4927,22 @@ expand_vec_double_ustrunc (rtx op_0, rtx op_1, machine_mode vec_mode)
emit_vlmax_insn (icode, BINARY_OP_VXRM_RNU, ops);
}
+/* Expand the standard name sstrunc<m><n>2 for double vector mode, like
+ DI => SI. we can leverage the vector fixed point vector narrowing
+ fixed-point clip directly. */
+
+void
+expand_vec_double_sstrunc (rtx op_0, rtx op_1, machine_mode vec_mode)
+{
+ insn_code icode;
+ rtx zero = CONST0_RTX (Xmode);
+ enum unspec unspec = UNSPEC_VNCLIP;
+ rtx ops[] = {op_0, op_1, zero};
+
+ icode = code_for_pred_narrow_clip_scalar (unspec, vec_mode);
+ emit_vlmax_insn (icode, BINARY_OP_VXRM_RNU, ops);
+}
+
/* Expand the standard name ustrunc<m><n>2 for double vector mode, like
DI => HI. we can leverage the vector fixed point vector narrowing
fixed-point clip directly. */
@@ -4941,6 +4957,20 @@ expand_vec_quad_ustrunc (rtx op_0, rtx op_1, machine_mode vec_mode,
expand_vec_double_ustrunc (op_0, double_rtx, double_mode);
}
+/* Expand the standard name sstrunc<m><n>2 for quad vector mode, like
+ DI => HI. we can leverage the vector fixed point vector narrowing
+ fixed-point clip directly. */
+
+void
+expand_vec_quad_sstrunc (rtx op_0, rtx op_1, machine_mode vec_mode,
+ machine_mode double_mode)
+{
+ rtx double_rtx = gen_reg_rtx (double_mode);
+
+ expand_vec_double_sstrunc (double_rtx, op_1, vec_mode);
+ expand_vec_double_sstrunc (op_0, double_rtx, double_mode);
+}
+
/* Expand the standard name ustrunc<m><n>2 for double vector mode, like
DI => QI. we can leverage the vector fixed point vector narrowing
fixed-point clip directly. */
@@ -4957,6 +4987,22 @@ expand_vec_oct_ustrunc (rtx op_0, rtx op_1, machine_mode vec_mode,
expand_vec_double_ustrunc (op_0, quad_rtx, quad_mode);
}
+/* Expand the standard name sstrunc<m><n>2 for oct vector mode, like
+ DI => QI. we can leverage the vector fixed point vector narrowing
+ fixed-point clip directly. */
+
+void
+expand_vec_oct_sstrunc (rtx op_0, rtx op_1, machine_mode vec_mode,
+ machine_mode double_mode, machine_mode quad_mode)
+{
+ rtx double_rtx = gen_reg_rtx (double_mode);
+ rtx quad_rtx = gen_reg_rtx (quad_mode);
+
+ expand_vec_double_sstrunc (double_rtx, op_1, vec_mode);
+ expand_vec_double_sstrunc (quad_rtx, double_rtx, double_mode);
+ expand_vec_double_sstrunc (op_0, quad_rtx, quad_mode);
+}
+
/* Vectorize popcount by the Wilkes-Wheeler-Gill algorithm that libgcc uses as
well. */
void