OSDN Git Service

gcc/
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 Sep 2007 09:45:36 +0000 (09:45 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 Sep 2007 09:45:36 +0000 (09:45 +0000)
* config/mips/mips.md (SHORT): Fix long line.
(SUBDI): New mode iterator.  Extend the shift-and-truncate insns
to QImode and HImoe.

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

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

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

index e250481..ff7bed5 100644 (file)
@@ -1,5 +1,11 @@
 2007-09-16  Richard Sandiford  <rsandifo@nildram.co.uk>
 
+       * config/mips/mips.md (SHORT): Fix long line.
+       (SUBDI): New mode iterator.  Extend the shift-and-truncate insns
+       to QImode and HImoe.
+
+2007-09-16  Richard Sandiford  <rsandifo@nildram.co.uk>
+
        * config/mips/mips.h (POINTERS_EXTEND_UNSIGNED): Define.
 
 2007-09-15  Zdenek Dvorak  <ook@ucw.cz>
index 842fa08..32a401c 100644 (file)
 ;; conditional-move-type condition is needed.
 (define_mode_iterator MOVECC [SI (DI "TARGET_64BIT") (CC "TARGET_HARD_FLOAT")])
 
-;; This mode iterator allows the QI and HI extension patterns to be defined from
-;; the same template.
+;; This mode iterator allows the QI and HI extension patterns to be
+;; defined from the same template.
 (define_mode_iterator SHORT [QI HI])
 
+;; Likewise the 64-bit truncate-and-shift patterns.
+(define_mode_iterator SUBDI [QI HI SI])
+
 ;; This mode iterator allows :ANYF to be used wherever a scalar or vector
 ;; floating-point mode is allowed.
 (define_mode_iterator ANYF [(SF "TARGET_HARD_FLOAT")
 ;; Combiner patterns to optimize shift/truncate combinations.
 
 (define_insn ""
-  [(set (match_operand:SI 0 "register_operand" "=d")
-        (truncate:SI
+  [(set (match_operand:SUBDI 0 "register_operand" "=d")
+        (truncate:SUBDI
          (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
-                       (match_operand:DI 2 "const_arith_operand" ""))))]
+                      (match_operand:DI 2 "const_arith_operand" ""))))]
   "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) >= 32"
   "dsra\t%0,%1,%2"
   [(set_attr "type" "shift")
    (set_attr "mode" "SI")])
 
 (define_insn ""
-  [(set (match_operand:SI 0 "register_operand" "=d")
-        (truncate:SI (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
-                                  (const_int 32))))]
+  [(set (match_operand:SUBDI 0 "register_operand" "=d")
+        (truncate:SUBDI
+         (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
+                      (const_int 32))))]
   "TARGET_64BIT && !TARGET_MIPS16"
   "dsra\t%0,%1,32"
   [(set_attr "type" "shift")
index 496c309..0721c01 100644 (file)
@@ -1,3 +1,7 @@
+2007-09-16  Richard Sandiford  <rsandifo@nildram.co.uk>
+
+       * gcc.target/mips/truncate-1.c: New test.
+
 2007-09-16  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/29396
diff --git a/gcc/testsuite/gcc.target/mips/truncate-1.c b/gcc/testsuite/gcc.target/mips/truncate-1.c
new file mode 100644 (file)
index 0000000..0607a70
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-mips-options "-O -mgp64" } */
+
+#define TEST(ID, TYPE, SHIFT)                          \
+  int __attribute__((nomips16))                                \
+  f##ID (unsigned long long y)                         \
+  {                                                    \
+    return (TYPE) ((TYPE) (y >> SHIFT) + 1);           \
+  }
+
+TEST (1, int, 32)
+TEST (2, short, 32)
+TEST (3, char, 32)
+TEST (4, int, 33)
+TEST (5, short, 33)
+TEST (6, char, 33)
+TEST (7, int, 61)
+TEST (8, short, 61)
+TEST (9, char, 61)
+
+/* { dg-final { scan-assembler-not "\tsll\t\[^\n\]*,0" } } */