public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Correct way to modify a .md file?
@ 2002-03-19 14:01 Robert Baruch
  0 siblings, 0 replies; only message in thread
From: Robert Baruch @ 2002-03-19 14:01 UTC (permalink / raw)
  To: gcc-help

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

I'm trying to add some optimizations to the m68k.md file. I'm just starting 
out, and I've read the gcc docs backwards and forwards, and it's beginning to 
make just a little sense.

Hopefully this question belongs on this mailing list?

Anyway, one thing I'm trying, just to see if it works, is to find anything 
which multiples an HI register by 40 and replace it with two shifts and an 
add. For example:

muls.w #40,%d0

becomes

move.w %d0,%d1
asl.w #2,%d0    /* 4x */
add.w %d1,%d0   /* 5x */
asl.w #3,%d0    /* 40x */

Would the correct way to do this in the .md file be the included patch? It 
*seems* to work, but I'd like to know if I'm using clobber/match_scratch 
properly, and if my define_insn really belongs here.

Thanks!

- --Rob


- --- gcc-2.95.3.orig/gcc/config/m68k/m68k.md     Tue Mar 19 16:50:26 2002
+++ gcc-2.95.3/gcc/config/m68k/m68k.md  Tue Mar 19 16:57:43 2002
@@ -2997,6 +2997,21 @@
 ^L
 ;; multiply instructions

+(define_insn ""
+  [(set (match_operand:HI 0 "general_operand" "=d")
+       (mult:HI (match_operand:HI 1 "general_operand" "%0")
+                (match_operand:HI 2 "const_int_operand" "n")))
+    (clobber (match_scratch:SI 3 "=d"))]
+  "!TARGET_68020 && !TARGET_5200 &&
+   INTVAL (operands[2]) == 40"
+  "*
+{
+  return \"move%.w %0,%3 /* RCB0 */\;
+          asl%.w #2,%0 /* RCB0 */\;
+          add%.w %3,%0 /* RCB0 */\;
+          asl%.w #3,%0 /* RCB0 */\"
+}")
+
 (define_insn "mulhi3"
   [(set (match_operand:HI 0 "general_operand" "=d")
        (mult:HI (match_operand:HI 1 "general_operand" "%0")

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8

iQA/AwUBPJe07NhpAoRIZLToEQIakACeIZKYayiTjaVUHoa0VE1kX0ODzPMAoL3S
+G6/grM5Ez6OeJS7NRLZMgWB
=1LHT
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-03-19 22:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-19 14:01 Correct way to modify a .md file? Robert Baruch

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).