Add peephole to eliminate unecessary clear instructions
authorJim Wilson <wilson@gcc.gnu.org>
Thu, 31 Dec 1992 20:55:33 +0000 (12:55 -0800)
committerJim Wilson <wilson@gcc.gnu.org>
Thu, 31 Dec 1992 20:55:33 +0000 (12:55 -0800)
in strict_low_part insn sequences.

From-SVN: r3015

gcc/config/m68k/m68k.md

index 47132135e5f44f10c13431ce4b3e34fd033b1508..09fb81b64b46f266c0a95d567b8c6599dea56dea 100644 (file)
   return \"\";
 }")
 
+(define_peephole
+  [(set (match_operand:SI 0 "register_operand" "=d")
+       (const_int 0))
+   (set (strict_low_part (subreg:HI (match_dup 0) 0))
+       (match_operand:HI 1 "general_operand" "rmn"))]
+  "strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0])"
+  "*
+{
+  if (GET_CODE (operands[1]) == CONST_INT)
+    {
+      if (operands[1] == const0_rtx
+         && (DATA_REG_P (operands[0])
+             || GET_CODE (operands[0]) == MEM)
+         /* clr insns on 68000 read before writing.
+            This isn't so on the 68010, but we have no alternative for it.  */
+         && (TARGET_68020
+             || !(GET_CODE (operands[0]) == MEM
+                  && MEM_VOLATILE_P (operands[0]))))
+       return \"clr%.w %0\";
+    }
+  return \"move%.w %1,%0\";
+}")
+
 ;; dbCC peepholes
 ;;
 ;; Turns