h8300.md: (stm_h8300s_2): Change the name to stm_h8300s_2_advanced.
authorKazu Hirata <kazu@cs.umass.edu>
Mon, 24 Nov 2003 16:58:30 +0000 (16:58 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Mon, 24 Nov 2003 16:58:30 +0000 (16:58 +0000)
* config/h8300/h8300.md: (stm_h8300s_2): Change the name to
stm_h8300s_2_advanced.
(stm_h8300s_2_normal): New.
(stm_h8300s_2): Likewise.
(stm_h8300s_3): Change the name to stm_h8300s_3_advanced.
(stm_h8300s_3_normal): New.
(stm_h8300s_3): Likewise.
(stm_h8300s_4): Change the name to stm_h8300s_4_advanced.
(stm_h8300s_4_normal): New.
(stm_h8300s_4): Likewise.
(ldm_h8300s_2): Change the name to ldm_h8300s_2_advanced.
(ldm_h8300s_2_normal): New.
(ldm_h8300s_2): Likewise.
(ldm_h8300s_3): Change the name to ldm_h8300s_3_advanced.
(ldm_h8300s_3_normal): New.
(ldm_h8300s_3): Likewise.
(ldm_h8300s_4): Change the name to ldm_h8300s_4_advanced.
(ldm_h8300s_4_normal): New.
(ldm_h8300s_4): Likewise.
(two peephole2's): Enable only with !TARGET_NORMAL_MODE.
(two peephole2's): New.

From-SVN: r73879

gcc/ChangeLog
gcc/config/h8300/h8300.md

index cc4f19c71cc4626a408baefc87860528cdc001ca..61f21cfb85462ed28e014737f6a4ca4585735632 100644 (file)
@@ -1,3 +1,27 @@
+2003-11-24  Kazu Hirata  <kazu@cs.umass.edu>
+
+       * config/h8300/h8300.md: (stm_h8300s_2): Change the name to
+       stm_h8300s_2_advanced.
+       (stm_h8300s_2_normal): New.
+       (stm_h8300s_2): Likewise.
+       (stm_h8300s_3): Change the name to stm_h8300s_3_advanced.
+       (stm_h8300s_3_normal): New.
+       (stm_h8300s_3): Likewise.
+       (stm_h8300s_4): Change the name to stm_h8300s_4_advanced.
+       (stm_h8300s_4_normal): New.
+       (stm_h8300s_4): Likewise.
+       (ldm_h8300s_2): Change the name to ldm_h8300s_2_advanced.
+       (ldm_h8300s_2_normal): New.
+       (ldm_h8300s_2): Likewise.
+       (ldm_h8300s_3): Change the name to ldm_h8300s_3_advanced.
+       (ldm_h8300s_3_normal): New.
+       (ldm_h8300s_3): Likewise.
+       (ldm_h8300s_4): Change the name to ldm_h8300s_4_advanced.
+       (ldm_h8300s_4_normal): New.
+       (ldm_h8300s_4): Likewise.
+       (two peephole2's): Enable only with !TARGET_NORMAL_MODE.
+       (two peephole2's): New.
+
 2003-11-24  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
 
        * genattrtab.c (simplify_cond): Update indices correctly.
index 8a0580308c2118e347e77f6ba83e4029fbc0009e..5ee68cfb672206bdaf072573237eb061623b908c 100644 (file)
   "TARGET_NORMAL_MODE"
   "")
 
-(define_insn "stm_h8300s_2"
+(define_insn "stm_h8300s_2_advanced"
   [(parallel
      [(set (reg:SI SP_REG)
           (plus:SI (reg:SI SP_REG) (const_int -8)))
           (match_operand:SI 0 "register_operand" ""))
       (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
           (match_operand:SI 1 "register_operand" ""))])]
-  "TARGET_H8300S
+  "TARGET_H8300S && !TARGET_NORMAL_MODE
+   && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
+       || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
+       || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
+  "stm.l\\t%S0-%S1,@-er7"
+  [(set_attr "cc" "none")
+   (set_attr "length" "4")])
+
+(define_insn "stm_h8300s_2_normal"
+  [(parallel
+     [(set (reg:HI SP_REG)
+          (plus:HI (reg:HI SP_REG) (const_int -8)))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
+          (match_operand:SI 0 "register_operand" ""))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
+          (match_operand:SI 1 "register_operand" ""))])]
+  "TARGET_H8300S && TARGET_NORMAL_MODE
    && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
        || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
        || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
   [(set_attr "cc" "none")
    (set_attr "length" "4")])
 
-(define_insn "stm_h8300s_3"
+(define_expand "stm_h8300s_2"
+  [(use (match_operand:SI 0 "register_operand" ""))
+   (use (match_operand:SI 1 "register_operand" ""))]
+  "TARGET_H8300S
+   && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
+       || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
+       || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
+  "
+{
+  if (!TARGET_NORMAL_MODE)
+    emit_insn (gen_stm_h8300s_2_advanced (operands[0], operands[1]));
+  else
+    emit_insn (gen_stm_h8300s_2_normal (operands[0], operands[1]));
+  DONE;
+}")
+
+(define_insn "stm_h8300s_3_advanced"
   [(parallel
      [(set (reg:SI SP_REG)
           (plus:SI (reg:SI SP_REG) (const_int -12)))
           (match_operand:SI 1 "register_operand" ""))
       (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
           (match_operand:SI 2 "register_operand" ""))])]
-  "TARGET_H8300S
+  "TARGET_H8300S && !TARGET_NORMAL_MODE
    && ((REGNO (operands[0]) == 0
        && REGNO (operands[1]) == 1
        && REGNO (operands[2]) == 2)
   [(set_attr "cc" "none")
    (set_attr "length" "4")])
 
-(define_insn "stm_h8300s_4"
+(define_insn "stm_h8300s_3_normal"
+  [(parallel
+     [(set (reg:HI SP_REG)
+          (plus:HI (reg:HI SP_REG) (const_int -12)))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
+          (match_operand:SI 0 "register_operand" ""))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
+          (match_operand:SI 1 "register_operand" ""))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
+          (match_operand:SI 2 "register_operand" ""))])]
+  "TARGET_H8300S && TARGET_NORMAL_MODE
+   && ((REGNO (operands[0]) == 0
+       && REGNO (operands[1]) == 1
+       && REGNO (operands[2]) == 2)
+       || (REGNO (operands[0]) == 4
+          && REGNO (operands[1]) == 5
+          && REGNO (operands[2]) == 6))"
+  "stm.l\\t%S0-%S2,@-er7"
+  [(set_attr "cc" "none")
+   (set_attr "length" "4")])
+
+(define_expand "stm_h8300s_3"
+  [(use (match_operand:SI 0 "register_operand" ""))
+   (use (match_operand:SI 1 "register_operand" ""))
+   (use (match_operand:SI 2 "register_operand" ""))]
+  "TARGET_H8300S
+   && ((REGNO (operands[0]) == 0
+       && REGNO (operands[1]) == 1
+       && REGNO (operands[2]) == 2)
+       || (REGNO (operands[0]) == 4
+          && REGNO (operands[1]) == 5
+          && REGNO (operands[2]) == 6))"
+  "
+{
+  if (!TARGET_NORMAL_MODE)
+    emit_insn (gen_stm_h8300s_3_advanced (operands[0], operands[1],
+                                         operands[2]));
+  else
+    emit_insn (gen_stm_h8300s_3_normal (operands[0], operands[1],
+                                       operands[2]));
+  DONE;
+}")
+
+(define_insn "stm_h8300s_4_advanced"
   [(parallel
      [(set (reg:SI SP_REG)
           (plus:SI (reg:SI SP_REG) (const_int -16)))
           (match_operand:SI 2 "register_operand" ""))
       (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -16)))
           (match_operand:SI 3 "register_operand" ""))])]
-  "TARGET_H8300S
+  "TARGET_H8300S && !TARGET_NORMAL_MODE
    && REGNO (operands[0]) == 0
    && REGNO (operands[1]) == 1
    && REGNO (operands[2]) == 2
   [(set_attr "cc" "none")
    (set_attr "length" "4")])
 
-(define_insn "ldm_h8300s_2"
+(define_insn "stm_h8300s_4_normal"
+  [(parallel
+     [(set (reg:HI SP_REG)
+          (plus:HI (reg:HI SP_REG) (const_int -16)))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
+          (match_operand:SI 0 "register_operand" ""))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
+          (match_operand:SI 1 "register_operand" ""))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
+          (match_operand:SI 2 "register_operand" ""))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -16)))
+          (match_operand:SI 3 "register_operand" ""))])]
+  "TARGET_H8300S && TARGET_NORMAL_MODE
+   && REGNO (operands[0]) == 0
+   && REGNO (operands[1]) == 1
+   && REGNO (operands[2]) == 2
+   && REGNO (operands[3]) == 3"
+  "stm.l\\t%S0-%S3,@-er7"
+  [(set_attr "cc" "none")
+   (set_attr "length" "4")])
+
+(define_expand "stm_h8300s_4"
+  [(use (match_operand:SI 0 "register_operand" ""))
+   (use (match_operand:SI 1 "register_operand" ""))
+   (use (match_operand:SI 2 "register_operand" ""))
+   (use (match_operand:SI 3 "register_operand" ""))]
+  "TARGET_H8300S
+   && REGNO (operands[0]) == 0
+   && REGNO (operands[1]) == 1
+   && REGNO (operands[2]) == 2
+   && REGNO (operands[3]) == 3"
+  "
+{
+  if (!TARGET_NORMAL_MODE)
+    emit_insn (gen_stm_h8300s_4_advanced (operands[0], operands[1],
+                                         operands[2], operands[3]));
+  else
+    emit_insn (gen_stm_h8300s_4_normal (operands[0], operands[1],
+                                       operands[2], operands[3]));
+  DONE;
+}")
+
+(define_insn "ldm_h8300s_2_advanced"
   [(parallel
      [(set (reg:SI SP_REG)
           (plus:SI (reg:SI SP_REG) (const_int 8)))
           (match_operand:SI 0 "register_operand" ""))
       (set (mem:SI (reg:SI SP_REG))
           (match_operand:SI 1 "register_operand" ""))])]
-  "TARGET_H8300S
+  "TARGET_H8300S && !TARGET_NORMAL_MODE
+   && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
+       || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
+       || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
+  "ldm.l\\t@er7+,%S0-%S1"
+  [(set_attr "cc" "none")
+   (set_attr "length" "4")])
+
+(define_insn "ldm_h8300s_2_normal"
+  [(parallel
+     [(set (reg:SI SP_REG)
+          (plus:SI (reg:SI SP_REG) (const_int 8)))
+      (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 4)))
+          (match_operand:SI 0 "register_operand" ""))
+      (set (mem:SI (reg:SI SP_REG))
+          (match_operand:SI 1 "register_operand" ""))])]
+  "TARGET_H8300S && TARGET_NORMAL_MODE
    && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
        || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
        || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
   [(set_attr "cc" "none")
    (set_attr "length" "4")])
 
-(define_insn "ldm_h8300s_3"
+(define_expand "ldm_h8300s_2"
+  [(use (match_operand:SI 0 "register_operand" ""))
+   (use (match_operand:SI 1 "register_operand" ""))]
+  "TARGET_H8300S
+   && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
+       || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
+       || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
+  "
+{
+  if (!TARGET_NORMAL_MODE)
+    emit_insn (gen_ldm_h8300s_2_advanced (operands[0], operands[1]));
+  else
+    emit_insn (gen_ldm_h8300s_2_normal (operands[0], operands[1]));
+  DONE;
+}")
+
+(define_insn "ldm_h8300s_3_advanced"
   [(parallel
      [(set (reg:SI SP_REG)
           (plus:SI (reg:SI SP_REG) (const_int 12)))
           (match_operand:SI 1 "register_operand" ""))
       (set (mem:SI (reg:SI SP_REG))
           (match_operand:SI 2 "register_operand" ""))])]
-  "TARGET_H8300S
+  "TARGET_H8300S && !TARGET_NORMAL_MODE
    && ((REGNO (operands[0]) == 0
        && REGNO (operands[1]) == 1
        && REGNO (operands[2]) == 2)
   [(set_attr "cc" "none")
    (set_attr "length" "4")])
 
-(define_insn "ldm_h8300s_4"
+(define_insn "ldm_h8300s_3_normal"
+  [(parallel
+     [(set (reg:HI SP_REG)
+          (plus:HI (reg:HI SP_REG) (const_int 12)))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 8)))
+          (match_operand:SI 0 "register_operand" ""))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 4)))
+          (match_operand:SI 1 "register_operand" ""))
+      (set (mem:SI (reg:HI SP_REG))
+          (match_operand:SI 2 "register_operand" ""))])]
+  "TARGET_H8300S && TARGET_NORMAL_MODE
+   && ((REGNO (operands[0]) == 0
+       && REGNO (operands[1]) == 1
+       && REGNO (operands[2]) == 2)
+       || (REGNO (operands[0]) == 4
+          && REGNO (operands[1]) == 5
+          && REGNO (operands[2]) == 6))"
+  "ldm.l\\t@er7+,%S0-%S2"
+  [(set_attr "cc" "none")
+   (set_attr "length" "4")])
+
+(define_expand "ldm_h8300s_3"
+  [(use (match_operand:SI 0 "register_operand" ""))
+   (use (match_operand:SI 1 "register_operand" ""))
+   (use (match_operand:SI 2 "register_operand" ""))]
+  "TARGET_H8300S
+   && ((REGNO (operands[0]) == 0
+       && REGNO (operands[1]) == 1
+       && REGNO (operands[2]) == 2)
+       || (REGNO (operands[0]) == 4
+          && REGNO (operands[1]) == 5
+          && REGNO (operands[2]) == 6))"
+  "
+{
+  if (!TARGET_NORMAL_MODE)
+    emit_insn (gen_ldm_h8300s_3_advanced (operands[0], operands[1],
+                                         operands[2]));
+  else
+    emit_insn (gen_ldm_h8300s_3_normal (operands[0], operands[1],
+                                       operands[2]));
+  DONE;
+}")
+
+(define_insn "ldm_h8300s_4_advanced"
   [(parallel
      [(set (reg:SI SP_REG)
           (plus:SI (reg:SI SP_REG) (const_int 16)))
           (match_operand:SI 2 "register_operand" ""))
       (set (mem:SI (reg:SI SP_REG))
           (match_operand:SI 3 "register_operand" ""))])]
-  "TARGET_H8300S
+  "TARGET_H8300S && !TARGET_NORMAL_MODE
+   && REGNO (operands[0]) == 0
+   && REGNO (operands[1]) == 1
+   && REGNO (operands[2]) == 2
+   && REGNO (operands[3]) == 3"
+  "ldm.l\\t@er7+,%S0-%S3"
+  [(set_attr "cc" "none")
+   (set_attr "length" "4")])
+
+(define_insn "ldm_h8300s_4_normal"
+  [(parallel
+     [(set (reg:HI SP_REG)
+          (plus:HI (reg:HI SP_REG) (const_int 16)))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 12)))
+          (match_operand:SI 0 "register_operand" ""))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 8)))
+          (match_operand:SI 1 "register_operand" ""))
+      (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 4)))
+          (match_operand:SI 2 "register_operand" ""))
+      (set (mem:SI (reg:HI SP_REG))
+          (match_operand:SI 3 "register_operand" ""))])]
+  "TARGET_H8300S && !TARGET_NORMAL_MODE
    && REGNO (operands[0]) == 0
    && REGNO (operands[1]) == 1
    && REGNO (operands[2]) == 2
   [(set_attr "cc" "none")
    (set_attr "length" "4")])
 
+(define_expand "ldm_h8300s_4"
+  [(use (match_operand:SI 0 "register_operand" ""))
+   (use (match_operand:SI 1 "register_operand" ""))
+   (use (match_operand:SI 2 "register_operand" ""))
+   (use (match_operand:SI 3 "register_operand" ""))]
+  "TARGET_H8300S && !TARGET_NORMAL_MODE
+   && REGNO (operands[0]) == 0
+   && REGNO (operands[1]) == 1
+   && REGNO (operands[2]) == 2
+   && REGNO (operands[3]) == 3"
+  "
+{
+  if (!TARGET_NORMAL_MODE)
+    emit_insn (gen_ldm_h8300s_4_advanced (operands[0], operands[1],
+                                         operands[2], operands[3]));
+  else
+    emit_insn (gen_ldm_h8300s_4_normal (operands[0], operands[1],
+                                       operands[2], operands[3]));
+  DONE;
+}")
+
 (define_expand "return"
   [(return)]
   "h8300_can_use_return_insn_p ()"
                    (plus:SI (reg:SI SP_REG) (const_int -4)))
               (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int -3)))
                    (match_operand:QI 0 "register_operand" ""))])]
-  "TARGET_H8300S"
+  "TARGET_H8300S && !TARGET_NORMAL_MODE"
   [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
        (match_dup 0))]
   "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
 
+(define_peephole2
+  [(parallel [(set (reg:HI SP_REG)
+                   (plus:HI (reg:HI SP_REG) (const_int -4)))
+              (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -3)))
+                   (match_operand:QI 0 "register_operand" ""))])]
+  "TARGET_H8300S && TARGET_NORMAL_MODE"
+  [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
+       (match_dup 0))]
+  "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
+
 ;; Convert a HImode push into an SImode push so that the
 ;; define_peephole2 below can cram multiple pushes into one stm.l.
 
                    (plus:SI (reg:SI SP_REG) (const_int -4)))
               (set (mem:HI (plus:SI (reg:SI SP_REG) (const_int -2)))
                    (match_operand:HI 0 "register_operand" ""))])]
-  "TARGET_H8300S"
+  "TARGET_H8300S && !TARGET_NORMAL_MODE"
   [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
        (match_dup 0))]
   "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
 
+(define_peephole2
+  [(parallel [(set (reg:HI SP_REG)
+                   (plus:HI (reg:HI SP_REG) (const_int -4)))
+              (set (mem:HI (plus:HI (reg:HI SP_REG) (const_int -2)))
+                   (match_operand:HI 0 "register_operand" ""))])]
+  "TARGET_H8300S && TARGET_NORMAL_MODE"
+  [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
+       (match_dup 0))]
+  "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
+
 ;; Cram four pushes into stm.l.
 
 (define_peephole2
        (match_operand:SI 2 "register_operand" ""))
    (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
        (match_operand:SI 3 "register_operand" ""))]
-  "TARGET_H8300S
+  "TARGET_H8300S && !TARGET_NORMAL_MODE
    && REGNO (operands[0]) == 0
    && REGNO (operands[1]) == 1
    && REGNO (operands[2]) == 2
                   (match_dup 3))])]
   "")
 
+(define_peephole2
+  [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
+       (match_operand:SI 0 "register_operand" ""))
+   (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
+       (match_operand:SI 1 "register_operand" ""))
+   (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
+       (match_operand:SI 2 "register_operand" ""))
+   (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
+       (match_operand:SI 3 "register_operand" ""))]
+  "TARGET_H8300S && TARGET_NORMAL_MODE
+   && REGNO (operands[0]) == 0
+   && REGNO (operands[1]) == 1
+   && REGNO (operands[2]) == 2
+   && REGNO (operands[3]) == 3"
+  [(parallel [(set (reg:HI SP_REG)
+                  (plus:HI (reg:HI SP_REG)
+                           (const_int -16)))
+             (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
+                  (match_dup 0))
+             (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
+                  (match_dup 1))
+             (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
+                  (match_dup 2))
+             (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -16)))
+                  (match_dup 3))])]
+  "")
+
 ;; Cram three pushes into stm.l.
 
 (define_peephole2
        (match_operand:SI 1 "register_operand" ""))
    (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
        (match_operand:SI 2 "register_operand" ""))]
-  "TARGET_H8300S
+  "TARGET_H8300S && !TARGET_NORMAL_MODE
    && ((REGNO (operands[0]) == 0
        && REGNO (operands[1]) == 1
        && REGNO (operands[2]) == 2)
                   (match_dup 2))])]
   "")
 
+(define_peephole2
+  [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
+       (match_operand:SI 0 "register_operand" ""))
+   (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
+       (match_operand:SI 1 "register_operand" ""))
+   (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
+       (match_operand:SI 2 "register_operand" ""))]
+  "TARGET_H8300S && TARGET_NORMAL_MODE
+   && ((REGNO (operands[0]) == 0
+       && REGNO (operands[1]) == 1
+       && REGNO (operands[2]) == 2)
+       || (REGNO (operands[0]) == 4
+          && REGNO (operands[1]) == 5
+          && REGNO (operands[2]) == 6))"
+  [(parallel [(set (reg:HI SP_REG)
+                  (plus:HI (reg:HI SP_REG)
+                           (const_int -12)))
+             (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
+                  (match_dup 0))
+             (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
+                  (match_dup 1))
+             (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
+                  (match_dup 2))])]
+  "")
+
 ;; Cram two pushes into stm.l.
 
 (define_peephole2
        (match_operand:SI 0 "register_operand" ""))
    (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
        (match_operand:SI 1 "register_operand" ""))]
-  "TARGET_H8300S
+  "TARGET_H8300S && !TARGET_NORMAL_MODE
    && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
        || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
        || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
                   (match_dup 1))])]
   "")
 
+(define_peephole2
+  [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
+       (match_operand:SI 0 "register_operand" ""))
+   (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
+       (match_operand:SI 1 "register_operand" ""))]
+  "TARGET_H8300S && TARGET_NORMAL_MODE
+   && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
+       || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
+       || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
+  [(parallel [(set (reg:HI SP_REG)
+                  (plus:HI (reg:HI SP_REG)
+                           (const_int -8)))
+             (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
+                  (match_dup 0))
+             (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
+                  (match_dup 1))])]
+  "")
+
 ;; Turn
 ;;
 ;;   mov.w #2,r0