public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, MIPS] add new peephole for 74k dspr2
@ 2012-08-16 15:13 Sandra Loosemore
  2012-08-19 17:23 ` Richard Sandiford
  0 siblings, 1 reply; 16+ messages in thread
From: Sandra Loosemore @ 2012-08-16 15:13 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 558 bytes --]

This patch adds a peephole optimization to use a clever trick to 
zero-initialize the two halves of an accumulator register with one 
instruction instead of a mtlo/mthi pair.  OK to check in?

-Sandra

2012-08-16  Sandra Loosemore  <sandra@codesourcery.com>
	    Julian Brown  <julian@codesourcery.com>
	    MIPS Technologies, Inc.

	gcc/
	* config/mips/mips-dspr2.md (UNSPEC_ACC_INIT): Declare.
	(mult peephole2): Add peephole that converts
	"mtlo $ac[1-3],$0; mthi $ac[1-3],$0" into
         "mult $ac[1-3],$0,$0".
	(*mips_acc_init): New insn for above.



[-- Attachment #2: peep.patch --]
[-- Type: text/x-patch, Size: 1496 bytes --]

Index: gcc/config/mips/mips-dspr2.md
===================================================================
--- gcc/config/mips/mips-dspr2.md	(revision 190437)
+++ gcc/config/mips/mips-dspr2.md	(working copy)
@@ -68,6 +68,7 @@
   UNSPEC_DPAQX_SA_W_PH
   UNSPEC_DPSQX_S_W_PH
   UNSPEC_DPSQX_SA_W_PH
+  UNSPEC_ACC_INIT
 ])
 
 (define_insn "mips_absq_s_qb"
@@ -630,3 +631,33 @@
   [(set_attr "type"	"dspmacsat")
    (set_attr "accum_in" "1")
    (set_attr "mode"	"SI")])
+
+;; Convert  mtlo $ac[1-3],$0  =>  mult $ac[1-3],$0,$0
+;;          mthi $ac[1-3],$0
+(define_peephole2
+  [(set (match_operand:SI 0 "register_operand" "")
+	(const_int 0))
+   (set (match_operand:SI 1 "register_operand" "")
+	(const_int 0))]
+  "ISA_HAS_DSPR2
+   && !TARGET_MIPS16
+   && !TARGET_64BIT
+   && true_regnum (operands[0]) >= DSP_ACC_REG_FIRST
+   && true_regnum (operands[0]) <= DSP_ACC_REG_LAST
+   && true_regnum (operands[0]) / 2 == true_regnum (operands[1]) / 2"
+  [(parallel [(set (match_dup 0) (const_int 0))
+	      (set (match_dup 1) (const_int 0))
+	      (unspec [(const_int 0)] UNSPEC_ACC_INIT)])]
+)
+
+(define_insn "*mips_acc_init"
+  [(parallel
+    [(set (match_operand:SI 0 "register_operand" "=a") (const_int 0))
+     (set (match_operand:SI 1 "register_operand" "=a") (const_int 0))
+     (unspec [(const_int 0)] UNSPEC_ACC_INIT)])]
+  "ISA_HAS_DSPR2
+   && !TARGET_MIPS16
+   && !TARGET_64BIT"
+  "mult\t%q0,$0,$0\t\t# Clear ACC HI/LO"
+  [(set_attr "type"	"imul")
+   (set_attr "mode"	"SI")])

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-10-11 15:26 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-16 15:13 [PATCH, MIPS] add new peephole for 74k dspr2 Sandra Loosemore
2012-08-19 17:23 ` Richard Sandiford
2012-08-22 14:26   ` Sandra Loosemore
2012-08-27 16:37     ` Richard Sandiford
2012-09-18 17:18       ` PING " Sandra Loosemore
2012-09-18 18:17         ` Richard Sandiford
2012-09-24 15:49           ` Maciej W. Rozycki
2012-09-24 21:40             ` Richard Sandiford
2012-09-25  0:52               ` Maciej W. Rozycki
2012-09-25  8:38                 ` Richard Sandiford
2012-09-25 10:29                   ` Richard Sandiford
2012-09-25 18:06                     ` Maciej W. Rozycki
2012-10-07  8:45                       ` Richard Sandiford
2012-10-08 23:23                         ` Maciej W. Rozycki
2012-10-10 20:00                           ` Richard Sandiford
2012-10-11 15:29                             ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).