@@ -201,7 +201,9 @@
(smax "smax")
(umin "umin")
(umax "umax")
- (mult "mul")])
+ (mult "mul")
+ (not "one_cmpl")
+ (neg "neg")])
;; <or_optab> code attributes
(define_code_attr or_optab [(ior "ior")
@@ -224,7 +226,9 @@
(smax "max")
(umin "minu")
(umax "maxu")
- (mult "mul")])
+ (mult "mul")
+ (not "not")
+ (neg "neg")])
; atomics code attribute
(define_code_attr atomic_optab
@@ -186,6 +186,17 @@ public:
}
};
+/* Implements vneg/vnot. */
+template<rtx_code CODE>
+class unop : public function_base
+{
+public:
+ rtx expand (function_expander &e) const override
+ {
+ return e.use_exact_insn (code_for_pred (CODE, e.vector_mode ()));
+ }
+};
+
static CONSTEXPR const vsetvl<false> vsetvl_obj;
static CONSTEXPR const vsetvl<true> vsetvlmax_obj;
static CONSTEXPR const loadstore<false, LST_UNIT_STRIDE, false> vle_obj;
@@ -228,6 +239,8 @@ static CONSTEXPR const binop<DIV> vdiv_obj;
static CONSTEXPR const binop<MOD> vrem_obj;
static CONSTEXPR const binop<UDIV> vdivu_obj;
static CONSTEXPR const binop<UMOD> vremu_obj;
+static CONSTEXPR const unop<NEG> vneg_obj;
+static CONSTEXPR const unop<NOT> vnot_obj;
/* Declare the function base NAME, pointing it to an instance
of class <NAME>_obj. */
@@ -276,5 +289,7 @@ BASE (vdiv)
BASE (vrem)
BASE (vdivu)
BASE (vremu)
+BASE (vneg)
+BASE (vnot)
} // end namespace riscv_vector
@@ -66,6 +66,8 @@ extern const function_base *const vdiv;
extern const function_base *const vrem;
extern const function_base *const vdivu;
extern const function_base *const vremu;
+extern const function_base *const vneg;
+extern const function_base *const vnot;
}
} // end namespace riscv_vector
@@ -63,40 +63,42 @@ DEF_RVV_FUNCTION (vsoxei16, indexed_loadstore, none_m_preds, all_v_scalar_ptr_ui
DEF_RVV_FUNCTION (vsoxei32, indexed_loadstore, none_m_preds, all_v_scalar_ptr_uint32_index_ops)
DEF_RVV_FUNCTION (vsoxei64, indexed_loadstore, none_m_preds, all_v_scalar_ptr_uint64_index_ops)
/* 11. Vector Integer Arithmetic Instructions. */
-DEF_RVV_FUNCTION (vadd, binop, full_preds, iu_vvv_ops)
-DEF_RVV_FUNCTION (vsub, binop, full_preds, iu_vvv_ops)
-DEF_RVV_FUNCTION (vand, binop, full_preds, iu_vvv_ops)
-DEF_RVV_FUNCTION (vor, binop, full_preds, iu_vvv_ops)
-DEF_RVV_FUNCTION (vxor, binop, full_preds, iu_vvv_ops)
-DEF_RVV_FUNCTION (vsll, binop, full_preds, iu_shift_vvv_ops)
-DEF_RVV_FUNCTION (vsra, binop, full_preds, iu_shift_vvv_ops)
-DEF_RVV_FUNCTION (vsrl, binop, full_preds, iu_shift_vvv_ops)
-DEF_RVV_FUNCTION (vmin, binop, full_preds, i_vvv_ops)
-DEF_RVV_FUNCTION (vmax, binop, full_preds, i_vvv_ops)
-DEF_RVV_FUNCTION (vminu, binop, full_preds, u_vvv_ops)
-DEF_RVV_FUNCTION (vmaxu, binop, full_preds, u_vvv_ops)
-DEF_RVV_FUNCTION (vmul, binop, full_preds, iu_vvv_ops)
-DEF_RVV_FUNCTION (vdiv, binop, full_preds, i_vvv_ops)
-DEF_RVV_FUNCTION (vrem, binop, full_preds, i_vvv_ops)
-DEF_RVV_FUNCTION (vdivu, binop, full_preds, u_vvv_ops)
-DEF_RVV_FUNCTION (vremu, binop, full_preds, u_vvv_ops)
-DEF_RVV_FUNCTION (vadd, binop, full_preds, iu_vvx_ops)
-DEF_RVV_FUNCTION (vsub, binop, full_preds, iu_vvx_ops)
-DEF_RVV_FUNCTION (vrsub, binop, full_preds, iu_vvx_ops)
-DEF_RVV_FUNCTION (vand, binop, full_preds, iu_vvx_ops)
-DEF_RVV_FUNCTION (vor, binop, full_preds, iu_vvx_ops)
-DEF_RVV_FUNCTION (vxor, binop, full_preds, iu_vvx_ops)
-DEF_RVV_FUNCTION (vsll, binop, full_preds, iu_shift_vvx_ops)
-DEF_RVV_FUNCTION (vsra, binop, full_preds, iu_shift_vvx_ops)
-DEF_RVV_FUNCTION (vsrl, binop, full_preds, iu_shift_vvx_ops)
-DEF_RVV_FUNCTION (vmin, binop, full_preds, i_vvx_ops)
-DEF_RVV_FUNCTION (vmax, binop, full_preds, i_vvx_ops)
-DEF_RVV_FUNCTION (vminu, binop, full_preds, u_vvx_ops)
-DEF_RVV_FUNCTION (vmaxu, binop, full_preds, u_vvx_ops)
-DEF_RVV_FUNCTION (vmul, binop, full_preds, iu_vvx_ops)
-DEF_RVV_FUNCTION (vdiv, binop, full_preds, i_vvx_ops)
-DEF_RVV_FUNCTION (vrem, binop, full_preds, i_vvx_ops)
-DEF_RVV_FUNCTION (vdivu, binop, full_preds, u_vvx_ops)
-DEF_RVV_FUNCTION (vremu, binop, full_preds, u_vvx_ops)
+DEF_RVV_FUNCTION (vadd, alu, full_preds, iu_vvv_ops)
+DEF_RVV_FUNCTION (vsub, alu, full_preds, iu_vvv_ops)
+DEF_RVV_FUNCTION (vand, alu, full_preds, iu_vvv_ops)
+DEF_RVV_FUNCTION (vor, alu, full_preds, iu_vvv_ops)
+DEF_RVV_FUNCTION (vxor, alu, full_preds, iu_vvv_ops)
+DEF_RVV_FUNCTION (vsll, alu, full_preds, iu_shift_vvv_ops)
+DEF_RVV_FUNCTION (vsra, alu, full_preds, iu_shift_vvv_ops)
+DEF_RVV_FUNCTION (vsrl, alu, full_preds, iu_shift_vvv_ops)
+DEF_RVV_FUNCTION (vmin, alu, full_preds, i_vvv_ops)
+DEF_RVV_FUNCTION (vmax, alu, full_preds, i_vvv_ops)
+DEF_RVV_FUNCTION (vminu, alu, full_preds, u_vvv_ops)
+DEF_RVV_FUNCTION (vmaxu, alu, full_preds, u_vvv_ops)
+DEF_RVV_FUNCTION (vmul, alu, full_preds, iu_vvv_ops)
+DEF_RVV_FUNCTION (vdiv, alu, full_preds, i_vvv_ops)
+DEF_RVV_FUNCTION (vrem, alu, full_preds, i_vvv_ops)
+DEF_RVV_FUNCTION (vdivu, alu, full_preds, u_vvv_ops)
+DEF_RVV_FUNCTION (vremu, alu, full_preds, u_vvv_ops)
+DEF_RVV_FUNCTION (vadd, alu, full_preds, iu_vvx_ops)
+DEF_RVV_FUNCTION (vsub, alu, full_preds, iu_vvx_ops)
+DEF_RVV_FUNCTION (vrsub, alu, full_preds, iu_vvx_ops)
+DEF_RVV_FUNCTION (vand, alu, full_preds, iu_vvx_ops)
+DEF_RVV_FUNCTION (vor, alu, full_preds, iu_vvx_ops)
+DEF_RVV_FUNCTION (vxor, alu, full_preds, iu_vvx_ops)
+DEF_RVV_FUNCTION (vsll, alu, full_preds, iu_shift_vvx_ops)
+DEF_RVV_FUNCTION (vsra, alu, full_preds, iu_shift_vvx_ops)
+DEF_RVV_FUNCTION (vsrl, alu, full_preds, iu_shift_vvx_ops)
+DEF_RVV_FUNCTION (vmin, alu, full_preds, i_vvx_ops)
+DEF_RVV_FUNCTION (vmax, alu, full_preds, i_vvx_ops)
+DEF_RVV_FUNCTION (vminu, alu, full_preds, u_vvx_ops)
+DEF_RVV_FUNCTION (vmaxu, alu, full_preds, u_vvx_ops)
+DEF_RVV_FUNCTION (vmul, alu, full_preds, iu_vvx_ops)
+DEF_RVV_FUNCTION (vdiv, alu, full_preds, i_vvx_ops)
+DEF_RVV_FUNCTION (vrem, alu, full_preds, i_vvx_ops)
+DEF_RVV_FUNCTION (vdivu, alu, full_preds, u_vvx_ops)
+DEF_RVV_FUNCTION (vremu, alu, full_preds, u_vvx_ops)
+DEF_RVV_FUNCTION (vneg, alu, full_preds, iu_v_ops)
+DEF_RVV_FUNCTION (vnot, alu, full_preds, iu_v_ops)
#undef DEF_RVV_FUNCTION
@@ -185,8 +185,8 @@ struct indexed_loadstore_def : public function_shape
}
};
-/* binop_def class. */
-struct binop_def : public build_base
+/* alu_def class. */
+struct alu_def : public build_base
{
char *get_name (function_builder &b, const function_instance &instance,
bool overloaded_p) const override
@@ -213,6 +213,6 @@ SHAPE(vsetvl, vsetvl)
SHAPE(vsetvl, vsetvlmax)
SHAPE(loadstore, loadstore)
SHAPE(indexed_loadstore, indexed_loadstore)
-SHAPE(binop, binop)
+SHAPE(alu, alu)
} // end namespace riscv_vector
@@ -28,7 +28,7 @@ extern const function_shape *const vsetvl;
extern const function_shape *const vsetvlmax;
extern const function_shape *const loadstore;
extern const function_shape *const indexed_loadstore;
-extern const function_shape *const binop;
+extern const function_shape *const alu;
}
} // end namespace riscv_vector
@@ -260,6 +260,10 @@ static CONSTEXPR const rvv_arg_type_info shift_vv_args[]
= {rvv_arg_type_info (RVV_BASE_vector),
rvv_arg_type_info (RVV_BASE_shift_vector), rvv_arg_type_info_end};
+/* A list of args for vector_type func (vector_type) function. */
+static CONSTEXPR const rvv_arg_type_info v_args[]
+ = {rvv_arg_type_info (RVV_BASE_vector), rvv_arg_type_info_end};
+
/* A list of args for vector_type func (vector_type, size) function. */
static CONSTEXPR const rvv_arg_type_info vector_size_args[]
= {rvv_arg_type_info (RVV_BASE_vector), rvv_arg_type_info (RVV_BASE_size),
@@ -469,6 +473,14 @@ static CONSTEXPR const rvv_op_info iu_shift_vvx_ops
rvv_arg_type_info (RVV_BASE_vector), /* Return type */
vector_size_args /* Args */};
+/* A static operand information for vector_type func (vector_type)
+ * function registration. */
+static CONSTEXPR const rvv_op_info iu_v_ops
+ = {iu_ops, /* Types */
+ OP_TYPE_v, /* Suffix */
+ rvv_arg_type_info (RVV_BASE_vector), /* Return type */
+ v_args /* Args */};
+
/* A list of all RVV intrinsic functions. */
static function_group_info function_groups[] = {
#define DEF_RVV_FUNCTION(NAME, SHAPE, PREDS, OPS_INFO) \
@@ -209,6 +209,8 @@
smax umax smin umin mult div udiv mod umod
])
+(define_code_iterator any_int_unop [neg not])
+
(define_code_iterator any_commutative_binop [plus and ior xor
smax umax smin umin mult
])
@@ -1531,3 +1531,33 @@
"vrsub.vx\t%0,%3,%4%p1"
[(set_attr "type" "vialu")
(set_attr "mode" "<MODE>")])
+
+;; -------------------------------------------------------------------------------
+;; ---- Predicated integer unary operations
+;; -------------------------------------------------------------------------------
+;; Includes:
+;; - vneg.v/vnot.v
+;; -------------------------------------------------------------------------------
+
+(define_insn "@pred_<optab><mode>"
+ [(set (match_operand:VI 0 "register_operand" "=vd, vr")
+ (if_then_else:VI
+ (unspec:<VM>
+ [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
+ (match_operand 4 "vector_length_operand" " rK, rK")
+ (match_operand 5 "const_int_operand" " i, i")
+ (match_operand 6 "const_int_operand" " i, i")
+ (match_operand 7 "const_int_operand" " i, i")
+ (reg:SI VL_REGNUM)
+ (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
+ (any_int_unop:VI
+ (match_operand:VI 3 "register_operand" " vr, vr"))
+ (match_operand:VI 2 "vector_merge_operand" "0vu,0vu")))]
+ "TARGET_VECTOR"
+ "v<insn>.v\t%0,%3%p1"
+ [(set_attr "type" "vialu")
+ (set_attr "mode" "<MODE>")
+ (set_attr "vl_op_idx" "4")
+ (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[5])"))
+ (set (attr "ma") (symbol_ref "riscv_vector::get_ta(operands[6])"))
+ (set (attr "avl_type") (symbol_ref "INTVAL (operands[7])"))])