* config/mips/mips.h (ISA_HAS_BADDU): New macro.
authornemet <nemet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Sep 2008 16:12:51 +0000 (16:12 +0000)
committernemet <nemet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Sep 2008 16:12:51 +0000 (16:12 +0000)
* config/mips/mips.md (*baddu_si_eb, *baddu_si_el,
*baddu_di<mode>): New patterns.

testsuite/
* gcc.target/mips/octeon-baddu-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140556 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/mips/mips.h
gcc/config/mips/mips.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/mips/octeon-baddu-1.c [new file with mode: 0644]

index d7d57c9..feee648 100644 (file)
@@ -1,3 +1,9 @@
+2008-09-22  Adam Nemet  <anemet@caviumnetworks.com>
+
+       * config/mips/mips.h (ISA_HAS_BADDU): New macro.
+       * config/mips/mips.md (*baddu_si_eb, *baddu_si_el,
+       *baddu_di<mode>): New patterns.
+
 2008-09-22  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/37145
index ab24869..02a8787 100644 (file)
@@ -1010,6 +1010,9 @@ enum mips_code_readable_setting {
    ? TARGET_LLSC && !TARGET_MIPS16     \
    : ISA_HAS_LL_SC)
 
+/* ISA includes the baddu instruction.  */
+#define ISA_HAS_BADDU          TARGET_OCTEON
+
 /* ISA includes the bbit* instructions.  */
 #define ISA_HAS_BBIT           TARGET_OCTEON
 
index 58d1fd6..f3fdaea 100644 (file)
   [(set_attr "type" "arith")
    (set_attr "mode" "SI")
    (set_attr "extended_mips16" "yes")])
+
+;; Combiner patterns for unsigned byte-add.
+
+(define_insn "*baddu_si_eb"
+  [(set (match_operand:SI 0 "register_operand" "=d")
+        (zero_extend:SI
+        (subreg:QI
+         (plus:SI (match_operand:SI 1 "register_operand" "d")
+                  (match_operand:SI 2 "register_operand" "d")) 3)))]
+  "ISA_HAS_BADDU && BYTES_BIG_ENDIAN"
+  "baddu\\t%0,%1,%2"
+  [(set_attr "type" "arith")])
+
+(define_insn "*baddu_si_el"
+  [(set (match_operand:SI 0 "register_operand" "=d")
+        (zero_extend:SI
+        (subreg:QI
+         (plus:SI (match_operand:SI 1 "register_operand" "d")
+                  (match_operand:SI 2 "register_operand" "d")) 0)))]
+  "ISA_HAS_BADDU && !BYTES_BIG_ENDIAN"
+  "baddu\\t%0,%1,%2"
+  [(set_attr "type" "arith")])
+
+(define_insn "*baddu_di<mode>"
+  [(set (match_operand:GPR 0 "register_operand" "=d")
+        (zero_extend:GPR
+        (truncate:QI
+         (plus:DI (match_operand:DI 1 "register_operand" "d")
+                  (match_operand:DI 2 "register_operand" "d")))))]
+  "ISA_HAS_BADDU && TARGET_64BIT"
+  "baddu\\t%0,%1,%2"
+  [(set_attr "type" "arith")])
 \f
 ;;
 ;;  ....................
index 53aacae..89851e5 100644 (file)
@@ -1,3 +1,7 @@
+2008-09-22  Adam Nemet  <anemet@caviumnetworks.com>
+
+       * gcc.target/mips/octeon-baddu-1.c: New test.
+
 2008-09-22  David Edelsohn  <edelsohn@gnu.org>
 
        PR rtl-optimization/33642
diff --git a/gcc/testsuite/gcc.target/mips/octeon-baddu-1.c b/gcc/testsuite/gcc.target/mips/octeon-baddu-1.c
new file mode 100644 (file)
index 0000000..97aacc5
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-mips-options "-O -march=octeon" } */
+/* { dg-final { scan-assembler-times "\tbaddu\t" 4 } } */
+/* { dg-final { scan-assembler-not "\tandi\t" } } */
+
+NOMIPS16 unsigned char
+g (long long a, long long b)
+{
+  return a + b;
+}
+
+NOMIPS16 unsigned long long
+h (unsigned long long a, unsigned long long b)
+{
+  unsigned char c = a + b;
+  return c;
+}
+
+NOMIPS16 long long
+ff (long long a, long long b)
+{
+  unsigned char c = a + b;
+  return c;
+}
+
+NOMIPS16 int
+gg (int a, int b)
+{
+  return (a + b) & 0xff;
+}