diff mbox

[v2] fix PR target/44606, reload bug on SPE

Message ID 20101022154100.GJ15897@codesourcery.com
State New
Headers show

Commit Message

Nathan Froyd Oct. 22, 2010, 3:41 p.m. UTC
The patch below addresses PR target/44606 in a slightly different way
than:

http://gcc.gnu.org/ml/gcc-patches/2010-09/msg02443.html

Bernd noticed that the code that tries to look for equivalences for
simple move insns with output reloads doesn't trigger all that often
anyway (as measured by bootstrap):

http://gcc.gnu.org/ml/gcc-patches/2010-10/msg00063.html

and proposed that we simply do:

http://gcc.gnu.org/ml/gcc-patches/2010-10/msg00390.html

everywhere, rather than trying to do one thing on the mainline and
another on release branches.  This strikes me as a better idea than the
original proposal, since Eric indicated that he felt deleting insns
during reload on the branches was too risky.

Tested as before (x86_64-unknown-linux-gnu and powerpc-linux-gnuspe).
OK to commit for mainline and branches?

-Nathan

gcc/
	PR target/44606
	* reload1.c (choose_reload_regs): Don't look for equivalences for
	output reloads of constant loads.

gcc/testsuite/
	PR target/44606
	* gcc.dg/pr44606.c: New test.
diff mbox

Patch

Index: gcc/ChangeLog
===================================================================
Index: gcc/testsuite/gcc.dg/pr44606.c
===================================================================
--- gcc/testsuite/gcc.dg/pr44606.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr44606.c	(revision 0)
@@ -0,0 +1,53 @@ 
+/* PR target/44606 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+typedef struct file FILE;
+extern FILE *stderr;
+extern int fprintf (FILE *, const char *, ...);
+extern void abort (void);
+
+ typedef struct _PixelPacket { 	unsigned char r, g, b; }
+ PixelPacket;
+#define ARRAYLEN(X) (sizeof(X)/sizeof(X[0]))
+PixelPacket q[6];
+#define COLS (ARRAYLEN(q) - 1)
+PixelPacket p[2*COLS + 22];
+#define Minify(POS, WEIGHT) do {	\
+	total_r += (WEIGHT)*(p[POS].r);	\
+	total_g += (WEIGHT)*(p[POS].g);	\
+	total_b += (WEIGHT)*(p[POS].b);	\
+} while (0)
+unsigned long columns = COLS;
+int main(void)
+{
+	static const unsigned char answers[COLS] = { 31, 32, 34, 35, 36 };
+	unsigned long x;
+	for (x = 0; x < sizeof(p)/sizeof(p[0]); x++) {
+		p[x].b = (x + 34) | 1;
+	}
+	for (x = 0; x < columns; x++) {
+		double total_r = 0, total_g = 0, total_b = 0;
+		double saved_r = 0, saved_g = 0, saved_b = 0;
+		Minify(2*x +  0,  3.0);
+		Minify(2*x +  1,  7.0);
+		Minify(2*x +  2,  7.0);
+		saved_r = total_r;
+		saved_g = total_g;
+		Minify(2*x + 11, 15.0);
+		Minify(2*x + 12,  7.0);
+		Minify(2*x + 18,  7.0);
+		Minify(2*x + 19, 15.0);
+		Minify(2*x + 20, 15.0);
+		Minify(2*x + 21,  7.0);
+		q[x].r = (unsigned char)(total_r/128.0 + 0.5);
+		q[x].g = (unsigned char)(total_g/128.0 + 0.5);
+		q[x].b = (unsigned char)(total_b/128.0 + 0.5);
+		fprintf(stderr, "r:%f g:%f b:%f\n", saved_r, saved_g, saved_b);
+	}
+	for (x = 0; x < COLS; x++) {
+		if (answers[x] != q[x].b)
+			abort();
+	}
+	return 0;
+}
Index: gcc/testsuite/ChangeLog
===================================================================
Index: gcc/reload1.c
===================================================================
--- gcc/reload1.c	(revision 165835)
+++ gcc/reload1.c	(working copy)
@@ -6598,17 +6598,6 @@  choose_reload_regs (struct insn_chain *c
 	      && (rld[r].nregs == max_group_size
 		  || ! reg_classes_intersect_p (rld[r].rclass, group_class)))
 	    search_equiv = rld[r].in;
-	  /* If this is an output reload from a simple move insn, look
-	     if an equivalence for the input is available.  */
-	  else if (inheritance && rld[r].in == 0 && rld[r].out != 0)
-	    {
-	      rtx set = single_set (insn);
-
-	      if (set
-		  && rtx_equal_p (rld[r].out, SET_DEST (set))
-		  && CONSTANT_P (SET_SRC (set)))
-		search_equiv = SET_SRC (set);
-	    }
 
 	  if (search_equiv)
 	    {