h8300-protos.h: Add a prototype for byte_accesses_mergeable_p.
authorKazu Hirata <kazu@cs.umass.edu>
Tue, 18 Mar 2003 01:25:57 +0000 (01:25 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Tue, 18 Mar 2003 01:25:57 +0000 (01:25 +0000)
* config/h8300/h8300-protos.h: Add a prototype for
byte_accesses_mergeable_p.
* config/h8300/h8300.c (byte_accesses_mergeable_p): New.
* config/h8300/h8300.md (*iorhi3_two_qi_mem): Likewise.
(a splitter): Likewise.
(*iorsi3_ashift_16_ashift_24): Likewise.
(*iorsi3_ashift_16_ashift_24_mem): Likewise.

From-SVN: r64518

gcc/ChangeLog
gcc/config/h8300/h8300-protos.h
gcc/config/h8300/h8300.c
gcc/config/h8300/h8300.md

index 26daccd8f196f359ef18d61263dc4a6ac5509323..f54a2738a30e40c6574197777dfe288ecf0a20c0 100644 (file)
@@ -1,3 +1,13 @@
+2003-03-17  Kazu Hirata  <kazu@cs.umass.edu>
+
+       * config/h8300/h8300-protos.h: Add a prototype for
+       byte_accesses_mergeable_p.
+       * config/h8300/h8300.c (byte_accesses_mergeable_p): New.
+       * config/h8300/h8300.md (*iorhi3_two_qi_mem): Likewise.
+       (a splitter): Likewise.
+       (*iorsi3_ashift_16_ashift_24): Likewise.
+       (*iorsi3_ashift_16_ashift_24_mem): Likewise.
+
 2003-03-17  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * dwarf2asm.h: Delete obsolete comment.
index 57f047ff64b94d9c2e72f8cdfa7e8bcb60746053..c0b6ad313105a402d324ca89fa98b624b413020f 100644 (file)
@@ -73,6 +73,7 @@ extern int iorxor_operator PARAMS ((rtx, enum machine_mode));
 
 extern int h8300_eightbit_constant_address_p PARAMS ((rtx));
 extern int h8300_tiny_constant_address_p PARAMS ((rtx));
+extern int byte_accesses_mergeable_p PARAMS ((rtx, rtx));
 
 /* Used in builtins.c */
 extern rtx h8300_return_addr_rtx PARAMS ((int, rtx));
index c50b5ad85ad7e7c995fd099418f099346f4867b2..057d2ae2b2b0d03a779f871603c7fc2e42655857 100644 (file)
@@ -4385,3 +4385,49 @@ h8300_tiny_constant_address_p (x)
          || ((TARGET_H8300S && !TARGET_NORMAL_MODE)
              && (IN_RANGE (addr, s1, s2) || IN_RANGE (addr, s3, s4))));
 }
+
+int
+byte_accesses_mergeable_p (addr1, addr2)
+     rtx addr1, addr2;
+{
+  HOST_WIDE_INT offset1, offset2;
+  rtx reg1, reg2;
+
+  if (REG_P (addr1))
+    {
+      reg1 = addr1;
+      offset1 = 0;
+    }
+  else if (GET_CODE (addr1) == PLUS
+          && REG_P (XEXP (addr1, 0))
+          && GET_CODE (XEXP (addr1, 1)) == CONST_INT)
+    {
+      reg1 = XEXP (addr1, 0);
+      offset1 = INTVAL (XEXP (addr1, 1));
+    }
+  else
+    return 0;
+
+  if (REG_P (addr2))
+    {
+      reg2 = addr2;
+      offset2 = 0;
+    }
+  else if (GET_CODE (addr2) == PLUS
+          && REG_P (XEXP (addr2, 0))
+          && GET_CODE (XEXP (addr2, 1)) == CONST_INT)
+    {
+      reg2 = XEXP (addr2, 0);
+      offset2 = INTVAL (XEXP (addr2, 1));
+    }
+  else
+    return 0;
+
+  if (((reg1 == stack_pointer_rtx && reg2 == stack_pointer_rtx)
+       || (reg1 == frame_pointer_rtx && reg2 == frame_pointer_rtx))
+      && offset1 % 2 == 0
+      && offset1 + 1 == offset2)
+    return 1;
+
+  return 0;
+}
index 4a97214e7ae3c7ad12b2c81b0f723e879f870d07..ccf3d6ea71d79236a01f5bacb191eee6ae9d2394 100644 (file)
   [(set_attr "cc" "clobber")
    (set_attr "length" "2")])
 
+(define_insn "*iorhi3_two_qi_mem"
+  [(set (match_operand:HI 0 "register_operand" "=&r")
+       (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" "m"))
+               (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "m") 0)
+                          (const_int 8))))]
+  ""
+  "mov.b\\t%X2,%t0\;mov.b\\t%X1,%s0"
+  [(set_attr "cc" "clobber")
+   (set_attr "length" "16")])
+
+(define_split
+  [(set (match_operand:HI 0 "register_operand" "")
+       (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" ""))
+               (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "") 0)
+                          (const_int 8))))]
+  "(TARGET_H8300H || TARGET_H8300S)
+   && reload_completed
+   && byte_accesses_mergeable_p (XEXP (operands[2], 0), XEXP (operands[1], 0))"
+  [(set (match_dup 0)
+       (match_dup 3))]
+  "operands[3] = gen_rtx_MEM (HImode, XEXP (operands[2], 0));")
+
 ;; ior:SI
 
 (define_insn "*iorsi3_two_hi"
   [(set_attr "length" "6")
    (set_attr "cc" "clobber")])
 
+(define_insn_and_split "*iorsi3_ashift_16_ashift_24"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+       (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
+                          (const_int 16))
+               (ashift:SI (match_operand:SI 2 "register_operand" "r")
+                          (const_int 24))))]
+  "(TARGET_H8300H || TARGET_H8300S)"
+  "#"
+  "&& reload_completed"
+  [(set (match_dup 3)
+        (ior:HI (ashift:HI (match_dup 4)
+                          (const_int 8))
+               (match_dup 3)))
+   (parallel [(set (match_dup 0)
+                  (ashift:SI (match_dup 0)
+                             (const_int 16)))
+             (clobber (scratch:QI))])]
+  "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
+   operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));")
+
+(define_insn_and_split "*iorsi3_ashift_16_ashift_24_mem"
+  [(set (match_operand:SI 0 "register_operand" "=&r")
+       (ior:SI (and:SI (ashift:SI (subreg:SI (match_operand:QI 1 "memory_operand" "m") 0)
+                                  (const_int 16))
+                       (const_int 16711680))
+               (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
+                          (const_int 24))))]
+  "(TARGET_H8300H || TARGET_H8300S)"
+  "#"
+  "&& reload_completed"
+  [(set (match_dup 3)
+        (ior:HI (zero_extend:HI (match_dup 1))
+               (ashift:HI (subreg:HI (match_dup 2) 0)
+                          (const_int 8))))
+   (parallel [(set (match_dup 0)
+                  (ashift:SI (match_dup 0)
+                             (const_int 16)))
+             (clobber (scratch:QI))])]
+  "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));")
+
 ;; Used to add the exponent of a float.
 
 (define_insn "*addsi3_shift"