===================================================================
@@ -21608,7 +21608,7 @@
/* Return a const_int vector of VAL with mode MODE. */
rtx
-mips_gen_const_int_vector (machine_mode mode, int val)
+mips_gen_const_int_vector (machine_mode mode, HOST_WIDE_INT val)
{
int nunits = GET_MODE_NUNITS (mode);
rtvec v = rtvec_alloc (nunits);
===================================================================
@@ -294,7 +294,7 @@
extern bool mips_const_vector_bitimm_set_p (rtx, machine_mode);
extern bool mips_const_vector_bitimm_clr_p (rtx, machine_mode);
extern rtx mips_msa_vec_parallel_const_half (machine_mode, bool);
-extern rtx mips_gen_const_int_vector (machine_mode, int);
+extern rtx mips_gen_const_int_vector (machine_mode, HOST_WIDE_INT);
extern bool mips_secondary_memory_needed (enum reg_class, enum reg_class,
machine_mode);
extern bool mips_cannot_change_mode_class (machine_mode,
===================================================================
@@ -1230,10 +1230,10 @@
(parallel [(const_int 0) (const_int 2)]))))
(mult:V2DI
(any_extend:V2DI
- (vec_select:V4SI (match_dup 1)
+ (vec_select:V2SI (match_dup 1)
(parallel [(const_int 1) (const_int 3)])))
(any_extend:V2DI
- (vec_select:V4SI (match_dup 2)
+ (vec_select:V2SI (match_dup 2)
(parallel [(const_int 1) (const_int 3)]))))))]
"ISA_HAS_MSA"
"dotp_<su>.d\t%w0,%w1,%w2"
@@ -1319,10 +1319,10 @@
(parallel [(const_int 0) (const_int 2)]))))
(mult:V2DI
(any_extend:V2DI
- (vec_select:V4SI (match_dup 2)
+ (vec_select:V2SI (match_dup 2)
(parallel [(const_int 1) (const_int 3)])))
(any_extend:V2DI
- (vec_select:V4SI (match_dup 3)
+ (vec_select:V2SI (match_dup 3)
(parallel [(const_int 1) (const_int 3)])))))
(match_operand:V2DI 1 "register_operand" "0")))]
"ISA_HAS_MSA"
@@ -1414,10 +1414,10 @@
(parallel [(const_int 0) (const_int 2)]))))
(mult:V2DI
(any_extend:V2DI
- (vec_select:V4SI (match_dup 2)
+ (vec_select:V2SI (match_dup 2)
(parallel [(const_int 1) (const_int 3)])))
(any_extend:V2DI
- (vec_select:V4SI (match_dup 3)
+ (vec_select:V2SI (match_dup 3)
(parallel [(const_int 1) (const_int 3)])))))))]
"ISA_HAS_MSA"
"dpsub_<su>.d\t%w0,%w2,%w3"
@@ -1688,7 +1688,7 @@
(define_insn "msa_fmax_a_<msafmt>"
[(set (match_operand:FMSA 0 "register_operand" "=f")
- (if_then_else
+ (if_then_else:FMSA
(gt (abs:FMSA (match_operand:FMSA 1 "register_operand" "f"))
(abs:FMSA (match_operand:FMSA 2 "register_operand" "f")))
(match_dup 1)
@@ -1709,7 +1709,7 @@
(define_insn "msa_fmin_a_<msafmt>"
[(set (match_operand:FMSA 0 "register_operand" "=f")
- (if_then_else
+ (if_then_else:FMSA
(lt (abs:FMSA (match_operand:FMSA 1 "register_operand" "f"))
(abs:FMSA (match_operand:FMSA 2 "register_operand" "f")))
(match_dup 1)
@@ -2174,7 +2174,7 @@
(define_insn "msa_max_a_<msafmt>"
[(set (match_operand:IMSA 0 "register_operand" "=f")
- (if_then_else
+ (if_then_else:IMSA
(gt (abs:IMSA (match_operand:IMSA 1 "register_operand" "f"))
(abs:IMSA (match_operand:IMSA 2 "register_operand" "f")))
(match_dup 1)
@@ -2191,7 +2191,7 @@
"ISA_HAS_MSA"
"@
max_s.<msafmt>\t%w0,%w1,%w2
- maxi_s.<msafmt>\t%w0,%w1,%B2"
+ maxi_s.<msafmt>\t%w0,%w1,%E2"
[(set_attr "type" "simd_int_arith")
(set_attr "mode" "<MODE>")])
@@ -2208,7 +2208,7 @@
(define_insn "msa_min_a_<msafmt>"
[(set (match_operand:IMSA 0 "register_operand" "=f")
- (if_then_else
+ (if_then_else:IMSA
(lt (abs:IMSA (match_operand:IMSA 1 "register_operand" "f"))
(abs:IMSA (match_operand:IMSA 2 "register_operand" "f")))
(match_dup 1)
@@ -2225,7 +2225,7 @@
"ISA_HAS_MSA"
"@
min_s.<msafmt>\t%w0,%w1,%w2
- mini_s.<msafmt>\t%w0,%w1,%B2"
+ mini_s.<msafmt>\t%w0,%w1,%E2"
[(set_attr "type" "simd_int_arith")
(set_attr "mode" "<MODE>")])
===================================================================
@@ -0,0 +1,69 @@
+/* { dg-do compile } */
+/* { dg-options "-mno-mips16 -mfp64 -mhard-float -mmsa" } */
+
+typedef int v4i32 __attribute__ ((vector_size(16)));
+typedef long long v2i64 __attribute__ ((vector_size(16)));
+typedef float v4f32 __attribute__ ((vector_size(16)));
+
+/* Test MSA AND.d optimization: generate BCLRI.d instead, for immediate const
+ vector operand with only one bit clear. */
+
+void
+and_d_msa (v2i64 *vx, v2i64 *vy)
+{
+ v2i64 and_vec = {0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF};
+ *vy = (*vx) & and_vec;
+}
+
+/* Test MSA dot product family for CSE optimization. */
+
+static v4i32 g = {0, 92, 93, 94};
+static v4i32 h = {12, 24, 36, 48};
+static v2i64 l = {84, 98};
+
+void
+dotp_d_msa (v2i64 *c)
+{
+ l = __builtin_msa_dotp_s_d (g, h);
+}
+
+void
+dpadd_d_msa (v2i64 *c)
+{
+ *c = __builtin_msa_dpadd_s_d (l, g, h);
+}
+
+void
+dpsub_d_msa (v2i64 *c)
+{
+ *c = __builtin_msa_dpsub_s_d (l, g, h);
+}
+
+/* Test MSA signed min/max immediate for correct assembly output. */
+
+void
+min_s_msa (v4i32 *vx, v4i32 *vy)
+{
+ *vy = __builtin_msa_mini_s_w (*vx, -15);
+}
+/* { dg-final { scan-assembler "-15" } } */
+
+void
+max_s_msa (v4i32 *vx, v4i32 *vy)
+{
+ *vy = __builtin_msa_maxi_s_w (*vx, -15);
+}
+/* { dg-final { scan-assembler "-15" } } */
+
+/* Test MSA min_a/max_a instructions for forward propagation optimization. */
+
+#define FUNC(NAME, TYPE, RETTYPE) RETTYPE NAME##_a_msa (TYPE *vx, TYPE *vy) \
+{ \
+ TYPE dest = __builtin_msa_##NAME##_a_w (*vx, *vy); \
+ return dest[0]; \
+}
+
+FUNC(fmin, v4f32, float)
+FUNC(fmax, v4f32, float)
+FUNC(min, v4i32, int)
+FUNC(max, v4i32, int)