public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch,AVR]: Add "w" constraint alternative to addhi3
@ 2012-03-08 13:45 Georg-Johann Lay
  2012-03-08 14:21 ` Denis Chertykov
  0 siblings, 1 reply; 2+ messages in thread
From: Georg-Johann Lay @ 2012-03-08 13:45 UTC (permalink / raw)
  To: gcc-patches; +Cc: Denis Chertykov, Eric Weddington

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

This patch adds a "w" alternative to *addhi3 and addhi3_clobber in order to
vote for class "w". This is similar to the orgiginal addhi3 insn up to version
4.6.  And there is no more explicit vote for "l" in addhi3_clobber, it's just "r".

Intention is to get a better usage of ADIW and SBIW instructions.

Would it be good to split the alternatives even more and add "?" costs to non-w
registers?

Moreover, it might be advantageous to move addhi3_clobber up and before *addhi3?

Passed without regressions.

Ok for trunk?

Johann

	* config/avr/avr.md (*addhi3, addhi3_clobber): Add "w" alternative
	for constants in [-63,63].

[-- Attachment #2: add-w.diff --]
[-- Type: text/x-patch, Size: 2222 bytes --]

Index: config/avr/avr.md
===================================================================
--- config/avr/avr.md	(revision 185100)
+++ config/avr/avr.md	(working copy)
@@ -1098,15 +1098,16 @@ (define_insn "*addhi3_sp"
    (set_attr "adjust_len" "addto_sp")])
 
 (define_insn "*addhi3"
-  [(set (match_operand:HI 0 "register_operand"          "=r,d,d")
-        (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0")
-                 (match_operand:HI 2 "nonmemory_operand" "r,s,n")))]
+  [(set (match_operand:HI 0 "register_operand"          "=r,d,!w,d")
+        (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0 ,0")
+                 (match_operand:HI 2 "nonmemory_operand" "r,s,IJ,n")))]
   ""
   {
     static const char * const asm_code[] =
       {
         "add %A0,%A2\;adc %B0,%B2",
         "subi %A0,lo8(-(%2))\;sbci %B0,hi8(-(%2))",
+        "",
         ""
       };
 
@@ -1115,9 +1116,9 @@ (define_insn "*addhi3"
 
     return avr_out_plus_noclobber (operands, NULL, NULL);
   }
-  [(set_attr "length" "2,2,2")
-   (set_attr "adjust_len" "*,*,out_plus_noclobber")
-   (set_attr "cc" "set_n,set_czn,out_plus_noclobber")])
+  [(set_attr "length" "2,2,2,2")
+   (set_attr "adjust_len" "*,*,out_plus_noclobber,out_plus_noclobber")
+   (set_attr "cc" "set_n,set_czn,out_plus_noclobber,out_plus_noclobber")])
 
 ;; Adding a constant to NO_LD_REGS might have lead to a reload of
 ;; that constant to LD_REGS.  We don't add a scratch to *addhi3
@@ -1155,10 +1156,10 @@ (define_peephole2 ; addhi3_clobber
               (clobber (match_dup 2))])])
 
 (define_insn "addhi3_clobber"
-  [(set (match_operand:HI 0 "register_operand"           "=d,l")
-        (plus:HI (match_operand:HI 1 "register_operand"  "%0,0")
-                 (match_operand:HI 2 "const_int_operand"  "n,n")))
-   (clobber (match_scratch:QI 3                          "=X,&d"))]
+  [(set (match_operand:HI 0 "register_operand"           "=!w,d,r")
+        (plus:HI (match_operand:HI 1 "register_operand"   "%0,0,0")
+                 (match_operand:HI 2 "const_int_operand"  "IJ,n,n")))
+   (clobber (match_scratch:QI 3                           "=X,X,&d"))]
   ""
   {
     gcc_assert (REGNO (operands[0]) == REGNO (operands[1]));

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

* Re: [Patch,AVR]: Add "w" constraint alternative to addhi3
  2012-03-08 13:45 [Patch,AVR]: Add "w" constraint alternative to addhi3 Georg-Johann Lay
@ 2012-03-08 14:21 ` Denis Chertykov
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Chertykov @ 2012-03-08 14:21 UTC (permalink / raw)
  To: Georg-Johann Lay; +Cc: gcc-patches, Eric Weddington

2012/3/8 Georg-Johann Lay <avr@gjlay.de>:
> This patch adds a "w" alternative to *addhi3 and addhi3_clobber in order to
> vote for class "w". This is similar to the orgiginal addhi3 insn up to version
> 4.6.  And there is no more explicit vote for "l" in addhi3_clobber, it's just "r".
>
> Intention is to get a better usage of ADIW and SBIW instructions.
>
> Would it be good to split the alternatives even more and add "?" costs to non-w
> registers?
>
> Moreover, it might be advantageous to move addhi3_clobber up and before *addhi3?

You can try and look at output.

>
> Passed without regressions.
>
> Ok for trunk?
>
> Johann
>
>        * config/avr/avr.md (*addhi3, addhi3_clobber): Add "w" alternative
>        for constants in [-63,63].


Approved.

Denis.

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

end of thread, other threads:[~2012-03-08 14:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-08 13:45 [Patch,AVR]: Add "w" constraint alternative to addhi3 Georg-Johann Lay
2012-03-08 14:21 ` Denis Chertykov

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