avr.md (*mulhi3_enh): Treat squaring smarter.
authorGeorg-Johann Lay <avr@gjlay.de>
Mon, 10 Oct 2011 09:57:02 +0000 (09:57 +0000)
committerGeorg-Johann Lay <gjl@gcc.gnu.org>
Mon, 10 Oct 2011 09:57:02 +0000 (09:57 +0000)
* config/avr/avr.md (*mulhi3_enh): Treat squaring smarter.

From-SVN: r179739

gcc/ChangeLog
gcc/config/avr/avr.md

index 7e7d6b288268012eb98fcc7ffc9ed6182eeb1318..6dc29639b2859f04b83462c61c7e83af91c37950 100644 (file)
@@ -1,3 +1,7 @@
+2011-10-10  Georg-Johann Lay  <avr@gjlay.de>
+
+       * config/avr/avr.md (*mulhi3_enh): Treat squaring smarter.
+
 2011-10-10  Georg-Johann Lay  <avr@gjlay.de>
 
        PR target/50652
index f1ac95d7f00480d5754cc76ab66650b2d73e0fc8..e17f7f2f2638a349fa95d0b7c8bc977a561a3aa8 100644 (file)
        (mult:HI (match_operand:HI 1 "register_operand" "r")
                 (match_operand:HI 2 "register_operand" "r")))]
   "AVR_HAVE_MUL"
-  "mul %A1,%A2
-       movw %0,r0
-       mul %A1,%B2
-       add %B0,r0
-       mul %B1,%A2
-       add %B0,r0
-       clr r1"
+  {
+    return REGNO (operands[1]) == REGNO (operands[2])
+           ? "mul %A1,%A1\;movw %0,r0\;mul %A1,%B1\;add %B0,r0\;add %B0,r0\;clr r1"
+           : "mul %A1,%A2\;movw %0,r0\;mul %A1,%B2\;add %B0,r0\;mul %B1,%A2\;add %B0,r0\;clr r1";
+  }
   [(set_attr "length" "7")
    (set_attr "cc" "clobber")])