Blame SOURCES/gcc34-rh235255.patch

6693b3
2007-04-21  Alexandre Oliva  <aoliva@redhat.com>
6693b3
6693b3
	* gcse.c (store_killed_in_insn): Handle PARALLELs.
6693b3
	(store_killed_in_pat): New.
6693b3
6693b3
	* gcc.dg/movsi-sm-1.c: New.
6693b3
6693b3
--- gcc/gcse.c.jj	2007-02-23 21:29:12.000000000 +0100
6693b3
+++ gcc/gcse.c	2007-07-18 20:41:08.000000000 +0200
6693b3
@@ -7427,6 +7427,40 @@ find_loads (rtx x, rtx store_pattern, in
6693b3
   return ret;
6693b3
 }
6693b3
 
6693b3
+static inline bool
6693b3
+store_killed_in_pat (rtx x, rtx pat, int after)
6693b3
+{
6693b3
+  if (GET_CODE (pat) == SET)
6693b3
+    {
6693b3
+      rtx dest = SET_DEST (pat);
6693b3
+
6693b3
+      if (GET_CODE (dest) == SIGN_EXTRACT
6693b3
+	  || GET_CODE (dest) == ZERO_EXTRACT)
6693b3
+	dest = XEXP (dest, 0);
6693b3
+
6693b3
+      /* Check for memory stores to aliased objects.  */
6693b3
+      if (GET_CODE (dest) == MEM
6693b3
+	  && !expr_equiv_p (dest, x))
6693b3
+	{
6693b3
+	  if (after)
6693b3
+	    {
6693b3
+	      if (output_dependence (dest, x))
6693b3
+		return true;
6693b3
+	    }
6693b3
+	  else
6693b3
+	    {
6693b3
+	      if (output_dependence (x, dest))
6693b3
+		return true;
6693b3
+	    }
6693b3
+	}
6693b3
+    }
6693b3
+
6693b3
+  if (find_loads (pat, x, after))
6693b3
+    return true;
6693b3
+
6693b3
+  return false;
6693b3
+}
6693b3
+
6693b3
 /* Check if INSN kills the store pattern X (is aliased with it).
6693b3
    AFTER is true if we are checking the case when store X occurs
6693b3
    after the insn.  Return true if it it does.  */
6693b3
@@ -7434,7 +7468,7 @@ find_loads (rtx x, rtx store_pattern, in
6693b3
 static bool
6693b3
 store_killed_in_insn (rtx x, rtx x_regs, rtx insn, int after)
6693b3
 {
6693b3
-  rtx reg, base, note;
6693b3
+  rtx reg, base, note, pat;
6693b3
 
6693b3
   if (!INSN_P (insn))
6693b3
     return false;
6693b3
@@ -7461,33 +7495,20 @@ store_killed_in_insn (rtx x, rtx x_regs,
6693b3
       return false;
6693b3
     }
6693b3
 
6693b3
-  if (GET_CODE (PATTERN (insn)) == SET)
6693b3
+  pat = PATTERN (insn);
6693b3
+  if (GET_CODE (pat) == SET)
6693b3
     {
6693b3
-      rtx pat = PATTERN (insn);
6693b3
-      rtx dest = SET_DEST (pat);
6693b3
-
6693b3
-      if (GET_CODE (dest) == SIGN_EXTRACT
6693b3
-	  || GET_CODE (dest) == ZERO_EXTRACT)
6693b3
-	dest = XEXP (dest, 0);
6693b3
-
6693b3
-      /* Check for memory stores to aliased objects.  */
6693b3
-      if (GET_CODE (dest) == MEM
6693b3
-	  && !expr_equiv_p (dest, x))
6693b3
-	{
6693b3
-	  if (after)
6693b3
-	    {
6693b3
-	      if (output_dependence (dest, x))
6693b3
-		return true;
6693b3
-	    }
6693b3
-	  else
6693b3
-	    {
6693b3
-	      if (output_dependence (x, dest))
6693b3
-		return true;
6693b3
-	    }
6693b3
-	}
6693b3
-      if (find_loads (SET_SRC (pat), x, after))
6693b3
+      if (store_killed_in_pat (x, pat, after))
6693b3
 	return true;
6693b3
     }
6693b3
+  else if (GET_CODE (pat) == PARALLEL)
6693b3
+    {
6693b3
+      int i;
6693b3
+
6693b3
+      for (i = 0; i < XVECLEN (pat, 0); i++)
6693b3
+	if (store_killed_in_pat (x, XVECEXP (pat, 0, i), after))
6693b3
+	  return true;
6693b3
+    }
6693b3
   else if (find_loads (PATTERN (insn), x, after))
6693b3
     return true;
6693b3
 
6693b3
--- gcc/testsuite/gcc.dg/movsi-sm-1.c.jj	2007-07-18 20:58:08.000000000 +0200
6693b3
+++ gcc/testsuite/gcc.dg/movsi-sm-1.c	2007-07-18 21:01:52.000000000 +0200
6693b3
@@ -0,0 +1,35 @@
6693b3
+/* { dg-do run } */
6693b3
+/* { dg-options "-O2" } */
6693b3
+/* { dg-options "-O2 -mtune=i386" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
6693b3
+
6693b3
+int ret = 1;
6693b3
+char buf[128];
6693b3
+
6693b3
+void
6693b3
+__attribute__((noinline))
6693b3
+bug (int arg)
6693b3
+{
6693b3
+  char str[28];
6693b3
+
6693b3
+  __builtin_memcpy (str, "Bugged!", 8);
6693b3
+
6693b3
+  if (arg & 0200)
6693b3
+    {
6693b3
+      __builtin_memcpy (str, "This is what we should get!", 28);
6693b3
+      ret = 0;
6693b3
+    }
6693b3
+
6693b3
+  if (arg & 0100)
6693b3
+    __builtin_memcpy (str, "Broken!", 8);
6693b3
+
6693b3
+  __builtin_sprintf (buf, "%s\n", str);
6693b3
+}
6693b3
+
6693b3
+int
6693b3
+main ()
6693b3
+{
6693b3
+  bug (0200);
6693b3
+  if (ret)
6693b3
+    return ret;
6693b3
+  return __builtin_strcmp (buf, "This is what we should get!\n") != 0;
6693b3
+}