aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMingjie Xing <mingjie.xing@gmail.com>2010-11-24 01:44:24 +0000
committerMingjie Xing <xmj@gcc.gnu.org>2010-11-24 01:44:24 +0000
commit19804c9217f1bb0604709d32f46c992f3f7fb268 (patch)
tree8d969a702f5142b55331339ffcd9e3f208003eb0 /gcc
parent299404a1ec3d2dc7e2b19ea79c3e9f3552b6215d (diff)
downloadgcc-19804c9217f1bb0604709d32f46c992f3f7fb268.zip
gcc-19804c9217f1bb0604709d32f46c992f3f7fb268.tar.gz
gcc-19804c9217f1bb0604709d32f46c992f3f7fb268.tar.bz2
Add loongson3a integer mul/div patterns
From-SVN: r167107
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/config/mips/loongson.md25
-rw-r--r--gcc/config/mips/mips.md17
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/mips/loongson3a-muldiv-1.c16
-rw-r--r--gcc/testsuite/gcc.target/mips/loongson3a-muldiv-2.c16
6 files changed, 77 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b7309ab..20a836a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2010-11-24 Mingjie Xing <mingjie.xing@gmail.com>
+
+ * config/mips/loongson.md: Change the description comment of the file
+ and update the copyright years.
+ (define_insn "<u>div<mode>3): Add loongson3a support.
+ (define_insn "<u>mod<mode>3"): Likewise.
+ * config/mips/mips.md: Rename mul<mode>3_mul3_ls2ef to
+ mul<mode>3_mul3_loongson.
+ (define_expand "mul<mode>3"): Add TARGET_LOONGSON_3A.
+ (define_insn "mul<mode>3_mul3_loongson"): Add loongson3a support.
+
2010-11-23 Joseph Myers <joseph@codesourcery.com>
* common.opt (initial_max_fld_align, flag_debug_asm,
diff --git a/gcc/config/mips/loongson.md b/gcc/config/mips/loongson.md
index 4f95c28..225f4d1 100644
--- a/gcc/config/mips/loongson.md
+++ b/gcc/config/mips/loongson.md
@@ -1,5 +1,6 @@
-;; Machine description for ST Microelectronics Loongson-2E/2F.
-;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+;; Machine description for Loongson-specific patterns, such as
+;; ST Microelectronics Loongson-2E/2F etc.
+;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
;; Contributed by CodeSourcery.
;;
;; This file is part of GCC.
@@ -497,14 +498,19 @@
"punpckl<V_stretch_half_suffix>\t%0,%1,%2"
[(set_attr "type" "fdiv")])
-;; Integer division and modulus.
+;; Integer division and modulus. For integer multiplication, see mips.md.
(define_insn "<u>div<mode>3"
[(set (match_operand:GPR 0 "register_operand" "=&d")
(any_div:GPR (match_operand:GPR 1 "register_operand" "d")
(match_operand:GPR 2 "register_operand" "d")))]
- "TARGET_LOONGSON_2EF"
- { return mips_output_division ("<d>div<u>.g\t%0,%1,%2", operands); }
+ "TARGET_LOONGSON_2EF || TARGET_LOONGSON_3A"
+ {
+ if (TARGET_LOONGSON_2EF)
+ return mips_output_division ("<d>div<u>.g\t%0,%1,%2", operands);
+ else
+ return mips_output_division ("gs<d>div<u>\t%0,%1,%2", operands);
+ }
[(set_attr "type" "idiv3")
(set_attr "mode" "<MODE>")])
@@ -512,7 +518,12 @@
[(set (match_operand:GPR 0 "register_operand" "=&d")
(any_mod:GPR (match_operand:GPR 1 "register_operand" "d")
(match_operand:GPR 2 "register_operand" "d")))]
- "TARGET_LOONGSON_2EF"
- { return mips_output_division ("<d>mod<u>.g\t%0,%1,%2", operands); }
+ "TARGET_LOONGSON_2EF || TARGET_LOONGSON_3A"
+ {
+ if (TARGET_LOONGSON_2EF)
+ return mips_output_division ("<d>mod<u>.g\t%0,%1,%2", operands);
+ else
+ return mips_output_division ("gs<d>mod<u>\t%0,%1,%2", operands);
+ }
[(set_attr "type" "idiv3")
(set_attr "mode" "<MODE>")])
diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md
index 2379eeb..31121f7 100644
--- a/gcc/config/mips/mips.md
+++ b/gcc/config/mips/mips.md
@@ -1324,9 +1324,9 @@
(match_operand:GPR 2 "register_operand")))]
""
{
- if (TARGET_LOONGSON_2EF)
- emit_insn (gen_mul<mode>3_mul3_ls2ef (operands[0], operands[1],
- operands[2]));
+ if (TARGET_LOONGSON_2EF || TARGET_LOONGSON_3A)
+ emit_insn (gen_mul<mode>3_mul3_loongson (operands[0], operands[1],
+ operands[2]));
else if (ISA_HAS_<D>MUL3)
emit_insn (gen_mul<mode>3_mul3 (operands[0], operands[1], operands[2]));
else if (TARGET_FIX_R4000)
@@ -1337,12 +1337,17 @@
DONE;
})
-(define_insn "mul<mode>3_mul3_ls2ef"
+(define_insn "mul<mode>3_mul3_loongson"
[(set (match_operand:GPR 0 "register_operand" "=d")
(mult:GPR (match_operand:GPR 1 "register_operand" "d")
(match_operand:GPR 2 "register_operand" "d")))]
- "TARGET_LOONGSON_2EF"
- "<d>multu.g\t%0,%1,%2"
+ "TARGET_LOONGSON_2EF || TARGET_LOONGSON_3A"
+{
+ if (TARGET_LOONGSON_2EF)
+ return "<d>multu.g\t%0,%1,%2";
+ else
+ return "gs<d>multu\t%0,%1,%2";
+}
[(set_attr "type" "imul3nc")
(set_attr "mode" "<MODE>")])
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a38ef10..cc9607e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-11-24 Mingjie Xing <mingjie.xing@gmail.com>
+
+ * gcc.target/mips/loongson3a-muldiv-1.c: New test.
+ * gcc.target/mips/loongson3a-muldiv-2.c: New test.
+
2010-11-23 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/opts-5.c: New test.
diff --git a/gcc/testsuite/gcc.target/mips/loongson3a-muldiv-1.c b/gcc/testsuite/gcc.target/mips/loongson3a-muldiv-1.c
new file mode 100644
index 0000000..cc15b83
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/loongson3a-muldiv-1.c
@@ -0,0 +1,16 @@
+/* { dg-options "-O2 -march=loongson3a" } */
+
+typedef int st;
+typedef unsigned int ut;
+
+NOMIPS16 st smul (st x, st y) { return x * y; }
+NOMIPS16 st sdiv (st x, st y) { return x / y + x % y; }
+
+NOMIPS16 ut umul (ut x, ut y) { return x * y; }
+NOMIPS16 ut udiv (ut x, ut y) { return x / y + x % y; }
+
+/* { dg-final { scan-assembler-times "\tgsmultu\t" 2 } } */
+/* { dg-final { scan-assembler-times "\tgsdivu\t" 1 } } */
+/* { dg-final { scan-assembler-times "\tgsmodu\t" 1 } } */
+/* { dg-final { scan-assembler-times "\tgsdiv\t" 1 } } */
+/* { dg-final { scan-assembler-times "\tgsmod\t" 1 } } */
diff --git a/gcc/testsuite/gcc.target/mips/loongson3a-muldiv-2.c b/gcc/testsuite/gcc.target/mips/loongson3a-muldiv-2.c
new file mode 100644
index 0000000..592b492
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/loongson3a-muldiv-2.c
@@ -0,0 +1,16 @@
+/* { dg-options "-O2 -march=loongson3a -mgp64" } */
+
+typedef long long st;
+typedef unsigned long long ut;
+
+NOMIPS16 st smul (st x, st y) { return x * y; }
+NOMIPS16 st sdiv (st x, st y) { return x / y + x % y; }
+
+NOMIPS16 ut umul (ut x, ut y) { return x * y; }
+NOMIPS16 ut udiv (ut x, ut y) { return x / y + x % y; }
+
+/* { dg-final { scan-assembler-times "\tgsdmultu\t" 2 } } */
+/* { dg-final { scan-assembler-times "\tgsddivu\t" 1 } } */
+/* { dg-final { scan-assembler-times "\tgsdmodu\t" 1 } } */
+/* { dg-final { scan-assembler-times "\tgsddiv\t" 1 } } */
+/* { dg-final { scan-assembler-times "\tgsdmod\t" 1 } } */