|| TARGET_SMARTMIPS) \
&& !TARGET_MIPS16)
+/* ISA has the "min" and "max" instructions (signed min/max). */
+#define ISA_HAS_MIN_MAX (TARGET_ALLEGREX)
+
/* ISA has the WSBH (word swap bytes within halfwords) instruction.
64-bit targets also provide DSBH and DSHD. */
#define ISA_HAS_WSBH ((mips_isa_rev >= 2 && !TARGET_MIPS16) \
DONE;
})
+;; Min and max.
+
+(define_insn "sminsi3"
+ [(set (match_operand:SI 0 "register_operand" "=d")
+ (smin:SI (match_operand:SI 1 "register_operand" "d")
+ (match_operand:SI 2 "register_operand" "d")))]
+ "ISA_HAS_MIN_MAX"
+ "min\t%0,%1,%2"
+ [(set_attr "type" "arith")
+ (set_attr "mode" "SI")])
+
+(define_insn "smaxsi3"
+ [(set (match_operand:SI 0 "register_operand" "=d")
+ (smax:SI (match_operand:SI 1 "register_operand" "d")
+ (match_operand:SI 2 "register_operand" "d")))]
+ "ISA_HAS_MIN_MAX"
+ "max\t%0,%1,%2"
+ [(set_attr "type" "arith")
+ (set_attr "mode" "SI")])
+
+
(define_expand "speculation_barrier"
[(unspec_volatile [(const_int 0)] VUNSPEC_SPECULATION_BARRIER)]
""
--- /dev/null
+/* { dg-options "-march=allegrex" } */
+
+NOMIPS16 int
+foo_max (int a, int b)
+{
+ return (a > b) ? a : b;
+}
+
+/* { dg-final { scan-assembler "\tmax\t" } } */
--- /dev/null
+/* { dg-options "-march=allegrex" } */
+
+NOMIPS16 int
+foo_min (int a, int b)
+{
+ return (a < b) ? a : b;
+}
+
+/* { dg-final { scan-assembler "\tmin\t" } } */