This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch,AVR]: Housekeeping: Clean-up notice_update_cc


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.

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;
     }
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]