public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch,AVR]: Housekeeping: Clean-up notice_update_cc
@ 2011-09-26 17:34 Georg-Johann Lay
  2011-09-26 19:36 ` Denis Chertykov
  0 siblings, 1 reply; 2+ messages in thread
From: Georg-Johann Lay @ 2011-09-26 17:34 UTC (permalink / raw)
  To: gcc-patches; +Cc: Denis Chertykov, Anatoly Sokolov, Eric Weddington

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

This patchlet represents the impact of insn ashrqi3 on CC by means of attribute
"cc" instead of hard-coding it in notice_update_cc.

Testsuite passes fine. Moreover, tested against code like

char c;

void func_1 (char a)
{
    a = a >> 7;
    if (a)
        c = a;
}

that triggered PR39633.

Ok?

Johann

	* config/avr/avr.md (ashrqi3): Split alternative "n"
	into its remaining parts C03, C04, C05, C06, C07 and describe
	impact on CC by attribute "cc" appropriately.
	* config/avr/avr.c (notice_update_cc): Clean-up: Don't patch CC0
	by digging RTX.


[-- Attachment #2: cleanup-update-cc.diff --]
[-- Type: text/x-patch, Size: 1990 bytes --]

Index: config/avr/avr.md
===================================================================
--- config/avr/avr.md	(revision 179191)
+++ config/avr/avr.md	(working copy)
@@ -2820,14 +2820,14 @@ (define_insn "*ashlsi3_const"
 ;; arithmetic shift right
 
 (define_insn "ashrqi3"
-  [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r,r")
-	(ashiftrt:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0,0")
-		     (match_operand:QI 2 "general_operand"  "r,L,P,K,n,Qm")))]
+  [(set (match_operand:QI 0 "register_operand"             "=r,r,r,r,r          ,r      ,r")
+        (ashiftrt:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0          ,0      ,0")
+                     (match_operand:QI 2 "general_operand"  "r,L,P,K,C03 C04 C05,C06 C07,Qm")))]
   ""
   "* return ashrqi3_out (insn, operands, NULL);"
-  [(set_attr "length" "5,0,1,2,5,9")
+  [(set_attr "length" "5,0,1,2,5,5,9")
    (set_attr "adjust_len" "ashrqi")
-   (set_attr "cc" "clobber,none,clobber,clobber,clobber,clobber")])
+   (set_attr "cc" "clobber,none,set_czn,set_czn,set_czn,clobber,clobber")])
 
 (define_insn "ashrhi3"
   [(set (match_operand:HI 0 "register_operand"             "=r,r,r,r,r,r,r")
Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c	(revision 179191)
+++ config/avr/avr.c	(working copy)
@@ -1574,26 +1574,6 @@ notice_update_cc (rtx body ATTRIBUTE_UNU
     case CC_CLOBBER:
       /* Insn doesn't leave CC in a usable state.  */
       CC_STATUS_INIT;
-
-      /* Correct CC for the ashrqi3 with the shift count as CONST_INT < 6 */
-      set = single_set (insn);
-      if (set)
-	{
-	  rtx src = SET_SRC (set);
-	  
-	  if (GET_CODE (src) == ASHIFTRT
-	      && GET_MODE (src) == QImode)
-	    {
-	      rtx x = XEXP (src, 1);
-
-	      if (CONST_INT_P (x)
-		  && IN_RANGE (INTVAL (x), 1, 5))
-		{
-		  cc_status.value1 = SET_DEST (set);
-		  cc_status.flags |= CC_OVERFLOW_UNUSABLE;
-		}
-	    }
-	}
       break;
     }
 }

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

* Re: [Patch,AVR]: Housekeeping: Clean-up notice_update_cc
  2011-09-26 17:34 [Patch,AVR]: Housekeeping: Clean-up notice_update_cc Georg-Johann Lay
@ 2011-09-26 19:36 ` Denis Chertykov
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Chertykov @ 2011-09-26 19:36 UTC (permalink / raw)
  To: Georg-Johann Lay; +Cc: gcc-patches, Anatoly Sokolov, Eric Weddington

2011/9/26 Georg-Johann Lay <avr@gjlay.de>:
> This patchlet represents the impact of insn ashrqi3 on CC by means of attribute
> "cc" instead of hard-coding it in notice_update_cc.
>
> Testsuite passes fine. Moreover, tested against code like
>
> char c;
>
> void func_1 (char a)
> {
>    a = a >> 7;
>    if (a)
>        c = a;
> }
>
> that triggered PR39633.
>
> Ok?
>
> Johann
>
>        * config/avr/avr.md (ashrqi3): Split alternative "n"
>        into its remaining parts C03, C04, C05, C06, C07 and describe
>        impact on CC by attribute "cc" appropriately.
>        * config/avr/avr.c (notice_update_cc): Clean-up: Don't patch CC0
>        by digging RTX.
>

Approved.

Denis.

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

end of thread, other threads:[~2011-09-26 18:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-26 17:34 [Patch,AVR]: Housekeeping: Clean-up notice_update_cc Georg-Johann Lay
2011-09-26 19:36 ` 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).