Blame SOURCES/gcc44-rh610785.patch

f28b6a
2010-07-07  Jakub Jelinek  <jakub@redhat.com>
f28b6a
f28b6a
	* tree-sra.c (sra_build_assignment): Don't add BIT_XOR_EXPR/MINUS_EXPR
f28b6a
	of signbit if signbit is the most significant bit of utype already.
f28b6a
f28b6a
	* gcc.c-torture/execute/20100707-1.c: New test.
f28b6a
f28b6a
--- gcc/tree-sra.c.jj	2010-05-13 13:08:52.000000000 +0200
f28b6a
+++ gcc/tree-sra.c	2010-07-06 19:50:09.000000000 +0200
f28b6a
@@ -2211,7 +2211,10 @@ sra_build_assignment (tree dst, tree src
f28b6a
 
f28b6a
       /* Perform sign extension, if required.
f28b6a
 	 ???  This should never be necessary.  */
f28b6a
-      if (!unsignedp)
f28b6a
+      if (!unsignedp
f28b6a
+	  && (TREE_INT_CST_LOW (width) != TYPE_PRECISION (utype)
f28b6a
+	      || (TREE_INT_CST_LOW (width)
f28b6a
+		  != GET_MODE_BITSIZE (TYPE_MODE (utype)))))
f28b6a
 	{
f28b6a
 	  tree signbit = int_const_binop (LSHIFT_EXPR,
f28b6a
 					  build_int_cst_wide (utype, 1, 0),
f28b6a
--- gcc/testsuite/gcc.c-torture/execute/20100707-1.c	2010-05-27 15:41:40.446237053 +0200
f28b6a
+++ gcc/testsuite/gcc.c-torture/execute/20100707-1.c	2010-07-06 13:55:35.000000000 +0200
f28b6a
@@ -0,0 +1,50 @@
f28b6a
+struct S { int s; };
f28b6a
+struct T { int w; int h; };
f28b6a
+int vr;
f28b6a
+
f28b6a
+inline struct T
f28b6a
+bar (const struct S * x)
f28b6a
+{
f28b6a
+  struct T t;
f28b6a
+  t.w = vr;
f28b6a
+  t.h = x->s;
f28b6a
+  return t;
f28b6a
+}
f28b6a
+
f28b6a
+__attribute__ ((noinline))
f28b6a
+void foo (struct S * w, unsigned char *x, int y, int *z[2])
f28b6a
+{
f28b6a
+  struct T t;
f28b6a
+  int i, j, k;
f28b6a
+  t = bar (w);
f28b6a
+  k = t.w + 2;
f28b6a
+  for (i = 0; i <= t.h; i++)
f28b6a
+    {
f28b6a
+      int *u = z[i > 0] + 1;
f28b6a
+      unsigned char *v;
f28b6a
+      int q = 0;
f28b6a
+      v = x + k * i + 1;
f28b6a
+      for (j = 0; j < t.w; j++)
f28b6a
+	{
f28b6a
+	  int m = u[j];
f28b6a
+	  if (m > y && !q && v[j - k] != 2)
f28b6a
+	    v[j] = 0;
f28b6a
+	}
f28b6a
+    }
f28b6a
+}
f28b6a
+
f28b6a
+unsigned char b[64];
f28b6a
+
f28b6a
+int
f28b6a
+main (void)
f28b6a
+{
f28b6a
+  int v[32], *z[2];
f28b6a
+  struct S s;
f28b6a
+  __builtin_memset (v, 0, sizeof (v));
f28b6a
+  vr = 16;
f28b6a
+  s.s = 16;
f28b6a
+  z[0] = v;
f28b6a
+  z[1] = v;
f28b6a
+  foo (&s, b + 32, -1, z);
f28b6a
+  return 0;
f28b6a
+}