* config/mips/mips.h (ISA_HAS_SEQ_SNE): New macro.
* config/mips/mips.c (mips_expand_scc): Also expand seq and sne if
second operand is a reg_imm10_operand.
* config/mips/mips.md (*seq_<GPR:mode><GPR2:mode>_seq,
*sne_<GPR:mode><GPR2:mode>_sne): New patterns.
(*seq_<GPR:mode><GPR2:mode>): Rename to
*seq_zero_<GPR:mode><GPR2:mode>. Don't match if
ISA_HAS_SEQ_SNE.
(*seq_<GPR:mode><GPR2:mode>_mips16): Rename to
*seq_zero_<GPR:mode><GPR2:mode>_mip16. Don't match if
ISA_HAS_SEQ_SNE.
(*sne_<GPR:mode><GPR2:mode>): Rename to
*sne_zero_<GPR:mode><GPR2:mode>. Don't match if
ISA_HAS_SEQ_SNE.
testsuite/
* gcc.target/mips/seq-1.c: New test.
* gcc.target/mips/octeon-seq-1.c: New test.
* gcc.target/mips/octeon-seq-2.c: New test.
* gcc.target/mips/octeon-seq-3.c: New test.
* gcc.target/mips/octeon-seq-4.c: New test.
* gcc.target/mips/scc-2.c: Also pass on sltiu.
* gcc.target/mips/scc-3.c: Likewise.
From-SVN: r140010
2008-09-04 Adam Nemet <anemet@caviumnetworks.com>
+ * config/mips/mips.h (ISA_HAS_SEQ_SNE): New macro.
+ * config/mips/mips.c (mips_expand_scc): Also expand seq and sne if
+ second operand is a reg_imm10_operand.
+ * config/mips/mips.md (*seq_<GPR:mode><GPR2:mode>_seq,
+ *sne_<GPR:mode><GPR2:mode>_sne): New patterns.
+ (*seq_<GPR:mode><GPR2:mode>): Rename to
+ *seq_zero_<GPR:mode><GPR2:mode>. Don't match if
+ ISA_HAS_SEQ_SNE.
+ (*seq_<GPR:mode><GPR2:mode>_mips16): Rename to
+ *seq_zero_<GPR:mode><GPR2:mode>_mip16. Don't match if
+ ISA_HAS_SEQ_SNE.
+ (*sne_<GPR:mode><GPR2:mode>): Rename to
+ *sne_zero_<GPR:mode><GPR2:mode>. Don't match if
+ ISA_HAS_SEQ_SNE.
+
+2008-09-04 Adam Nemet <anemet@caviumnetworks.com>
+
* config/mips/mips.h (ISA_HAS_EXTS): New macro.
* config/mips/mips.md (*ashr_trunc<mode>): Name the pattern
combining an arithmetic right shift by more than 31 and a
if (code == EQ || code == NE)
{
- rtx zie = mips_zero_if_equal (cmp_operands[0], cmp_operands[1]);
- mips_emit_binary (code, target, zie, const0_rtx);
+ if (ISA_HAS_SEQ_SNE
+ && reg_imm10_operand (cmp_operands[1], GET_MODE (cmp_operands[1])))
+ mips_emit_binary (code, target, cmp_operands[0], cmp_operands[1]);
+ else
+ {
+ rtx zie = mips_zero_if_equal (cmp_operands[0], cmp_operands[1]);
+ mips_emit_binary (code, target, zie, const0_rtx);
+ }
}
else
mips_emit_int_order_test (code, 0, target,
/* ISA includes the exts instruction. */
#define ISA_HAS_EXTS TARGET_OCTEON
+/* ISA includes the seq and sne instructions. */
+#define ISA_HAS_SEQ_SNE TARGET_OCTEON
+
/* ISA includes the pop instruction. */
#define ISA_HAS_POP TARGET_OCTEON
\f
""
{ if (mips_expand_scc (EQ, operands[0])) DONE; else FAIL; })
-(define_insn "*seq_<GPR:mode><GPR2:mode>"
+(define_insn "*seq_zero_<GPR:mode><GPR2:mode>"
[(set (match_operand:GPR2 0 "register_operand" "=d")
(eq:GPR2 (match_operand:GPR 1 "register_operand" "d")
(const_int 0)))]
- "!TARGET_MIPS16"
+ "!TARGET_MIPS16 && !ISA_HAS_SEQ_SNE"
"sltu\t%0,%1,1"
[(set_attr "type" "slt")
(set_attr "mode" "<GPR:MODE>")])
-(define_insn "*seq_<GPR:mode><GPR2:mode>_mips16"
+(define_insn "*seq_zero_<GPR:mode><GPR2:mode>_mips16"
[(set (match_operand:GPR2 0 "register_operand" "=t")
(eq:GPR2 (match_operand:GPR 1 "register_operand" "d")
(const_int 0)))]
- "TARGET_MIPS16"
+ "TARGET_MIPS16 && !ISA_HAS_SEQ_SNE"
"sltu\t%1,1"
[(set_attr "type" "slt")
(set_attr "mode" "<GPR:MODE>")])
+;; Generate sltiu unless using seq results in better code.
+(define_insn "*seq_<GPR:mode><GPR2:mode>_seq"
+ [(set (match_operand:GPR2 0 "register_operand" "=d,d,d")
+ (eq:GPR2 (match_operand:GPR 1 "register_operand" "%d,d,d")
+ (match_operand:GPR 2 "reg_imm10_operand" "d,J,YB")))]
+ "ISA_HAS_SEQ_SNE"
+ "@
+ seq\t%0,%1,%2
+ sltiu\t%0,%1,1
+ seqi\t%0,%1,%2"
+ [(set_attr "type" "slt")
+ (set_attr "mode" "<GPR:MODE>")])
+
;; "sne" uses sltu instructions in which the first operand is $0.
;; This isn't possible in mips16 code.
"!TARGET_MIPS16"
{ if (mips_expand_scc (NE, operands[0])) DONE; else FAIL; })
-(define_insn "*sne_<GPR:mode><GPR2:mode>"
+(define_insn "*sne_zero_<GPR:mode><GPR2:mode>"
[(set (match_operand:GPR2 0 "register_operand" "=d")
(ne:GPR2 (match_operand:GPR 1 "register_operand" "d")
(const_int 0)))]
- "!TARGET_MIPS16"
+ "!TARGET_MIPS16 && !ISA_HAS_SEQ_SNE"
"sltu\t%0,%.,%1"
[(set_attr "type" "slt")
(set_attr "mode" "<GPR:MODE>")])
+;; Generate sltu unless using sne results in better code.
+(define_insn "*sne_<GPR:mode><GPR2:mode>_sne"
+ [(set (match_operand:GPR2 0 "register_operand" "=d,d,d")
+ (ne:GPR2 (match_operand:GPR 1 "register_operand" "%d,d,d")
+ (match_operand:GPR 2 "reg_imm10_operand" "d,J,YB")))]
+ "ISA_HAS_SEQ_SNE"
+ "@
+ sne\t%0,%1,%2
+ sltu\t%0,%.,%1
+ snei\t%0,%1,%2"
+ [(set_attr "type" "slt")
+ (set_attr "mode" "<GPR:MODE>")])
+
(define_expand "sgt<u>"
[(set (match_operand:SI 0 "register_operand")
(any_gt:SI (match_dup 1)
2008-09-04 Adam Nemet <anemet@caviumnetworks.com>
+ * gcc.target/mips/seq-1.c: New test.
+ * gcc.target/mips/octeon-seq-1.c: New test.
+ * gcc.target/mips/octeon-seq-2.c: New test.
+ * gcc.target/mips/octeon-seq-3.c: New test.
+ * gcc.target/mips/octeon-seq-4.c: New test.
+ * gcc.target/mips/scc-2.c: Also pass on sltiu.
+ * gcc.target/mips/scc-3.c: Likewise.
+
+2008-09-04 Adam Nemet <anemet@caviumnetworks.com>
+
* gcc.target/mips/truncate-2.c: New test.
* gcc.target/mips/octeon-exts-1.c: New test.
* gcc.target/mips/octeon-exts-2.c: New test.
--- /dev/null
+/* Check if we expand seq and sne. */
+
+/* { dg-do compile } */
+/* { dg-mips-options "-march=octeon" } */
+/* { dg-final { scan-assembler-times "\tseq\t|\tseqi\t" 4 } } */
+/* { dg-final { scan-assembler-times "\tsne\t|\tsnei\t" 4 } } */
+
+#define TEST(N, LHS, REL, RHS) \
+ NOMIPS16 int f##N (int a, int b) { return LHS REL RHS; }
+
+TEST (0, a, ==, b);
+TEST (1, a, ==, 23);
+TEST (2, a, ==, 511);
+TEST (3, a, ==, -200);
+
+TEST (10, a, !=, b);
+TEST (11, a, !=, 1);
+TEST (12, a, !=, 350);
+TEST (13, a, !=, -512);
--- /dev/null
+/* { dg-do compile } */
+/* { dg-mips-options "-march=octeon -mgp64" } */
+/* { dg-final { scan-assembler-times "\tseq\t|\tseqi\t" 3 } } */
+/* { dg-final { scan-assembler-times "\tsne\t|\tsnei\t" 3 } } */
+
+#define TEST(N, LHS, REL, RHS) \
+ NOMIPS16 long long f##N (long long a, long long b) { return LHS REL RHS; }
+
+TEST (0, a, ==, b);
+TEST (1, a, ==, 23);
+TEST (2, a, ==, 511);
+
+TEST (3, a, !=, b);
+TEST (4, a, !=, 1);
+TEST (5, a, !=, 350);
--- /dev/null
+/* { dg-do compile } */
+/* { dg-mips-options "-O -march=octeon -mgp64" } */
+
+/* { dg-final { scan-assembler-not "and\t\|andi\t\|ext\t\|sll\t\|srl\t" } } */
+/* { dg-final { scan-assembler-times "\tseqi\t\|\tsnei\t" 4 } } */
+
+
+#define TEST(N, LHS, REL, RHS) \
+ NOMIPS16 long long w##N (int a, int b) {return LHS REL RHS;} \
+ NOMIPS16 int n##N (long long a, long long b) {return LHS REL RHS;} \
+
+TEST (eq, a, ==, 10);
+TEST (ne, a, !=, 32);
--- /dev/null
+/* { dg-do compile } */
+/* { dg-mips-options "-O2 -march=octeon" } */
+/* { dg-final { scan-assembler-not "xor" } } */
+
+unsigned
+m (unsigned e);
+
+NOMIPS16 void
+f (unsigned i)
+{
+ unsigned j = m (i);
+ h (j, i != j);
+}
/* { dg-mips-options "-O -mgp64" } */
/* { dg-final { scan-assembler-not "and\t\|andi\t\|ext\t\|sll\t\|srl\t" } } */
-/* { dg-final { scan-assembler-times "slt\t\|sltu\t" 12 } } */
+/* { dg-final { scan-assembler-times "slt\t\|slti?u\t" 12 } } */
#define TEST(N, LHS, REL, RHS) \
/* { dg-add-options mips16_attribute } */
/* { dg-final { scan-assembler-not "and\t\|andi\t\|ext\t\|sll\t\|srl\t" } } */
-/* { dg-final { scan-assembler-times "slt\t\|sltu\t" 8 } } */
+/* { dg-final { scan-assembler-times "slt\t\|slti?u\t" 8 } } */
#define TEST(N, LHS, REL, RHS) \
--- /dev/null
+/* { dg-do compile } */
+/* { dg-final { scan-assembler-times "\tsltu\t|\tsltiu\t" 4 } } */
+
+#define TEST(N, LHS, REL, RHS) \
+ NOMIPS16 int f##N (int a, int b) { return LHS REL RHS; }
+
+TEST (0, a, ==, 0);
+TEST (1, a, ==, 600);
+TEST (10, a, !=, 0);
+TEST (11, a, !=, -800);