New define_splits to recombine output from LEGITIMIZE_ADDRESS.
authorJim Wilson <wilson@gcc.gnu.org>
Tue, 17 Sep 1996 19:08:58 +0000 (12:08 -0700)
committerJim Wilson <wilson@gcc.gnu.org>
Tue, 17 Sep 1996 19:08:58 +0000 (12:08 -0700)
From-SVN: r12729

gcc/config/sh/sh.md

index 9e9fd9481d474cfe634a4ed34f4f30600a8b26b7..729884c3bc494ea077d92d0c8949c2c3d3e68778 100644 (file)
     FAIL;
 }")
 
+;; If a base address generated by LEGITIMIZE_ADDRESS for SImode is
+;; used only once, let combine add in the index again.
+
+(define_split
+  [(set (match_operand:SI 0 "register_operand" "")
+       (match_operand:SI 1 "" ""))
+   (clobber (match_operand 2 "register_operand" ""))]
+  "! reload_in_progress && ! reload_completed"
+  [(use (reg:SI 0))]
+  "
+{
+  rtx addr, reg, const_int;
+
+  if (GET_CODE (operands[1]) != MEM)
+    FAIL;
+  addr = XEXP (operands[1], 0);
+  if (GET_CODE (addr) != PLUS)
+    FAIL;
+  reg = XEXP (addr, 0);
+  const_int = XEXP (addr, 1);
+  if (GET_CODE (reg) != REG || GET_CODE (const_int) != CONST_INT)
+    FAIL;
+  emit_move_insn (operands[2], const_int);
+  emit_move_insn (operands[0],
+                 change_address (operands[1], VOIDmode,
+                                 gen_rtx (PLUS, SImode, reg, operands[2])));
+  DONE;
+}")
+
+(define_split
+  [(set (match_operand:SI 1 "" "")
+       (match_operand:SI 0 "register_operand" ""))
+   (clobber (match_operand 2 "register_operand" ""))]
+  "! reload_in_progress && ! reload_completed"
+  [(use (reg:SI 0))]
+  "
+{
+  rtx addr, reg, const_int;
+
+  if (GET_CODE (operands[1]) != MEM)
+    FAIL;
+  addr = XEXP (operands[1], 0);
+  if (GET_CODE (addr) != PLUS)
+    FAIL;
+  reg = XEXP (addr, 0);
+  const_int = XEXP (addr, 1);
+  if (GET_CODE (reg) != REG || GET_CODE (const_int) != CONST_INT)
+    FAIL;
+  emit_move_insn (operands[2], const_int);
+  emit_move_insn (change_address (operands[1], VOIDmode,
+                                 gen_rtx (PLUS, SImode, reg, operands[2])),
+                 operands[0]);
+  DONE;
+}")
+
 (define_expand "movdf"
   [(set (match_operand:DF 0 "general_movdst_operand" "")
        (match_operand:DF 1 "general_movsrc_operand" ""))]