Patchwork [rs6000] Fix creation of invalid CONST_VECTORs

login
register
mail settings
Submitter Richard Sandiford
Date Aug. 23, 2011, 10:44 a.m.
Message ID <g4ei0co19i.fsf@richards-thinkpad.stglab.manchester.uk.ibm.com>
Download mbox | patch
Permalink /patch/111074/
State New
Headers show

Comments

Richard Sandiford - Aug. 23, 2011, 10:44 a.m.
My patches to more "accurately" detect the number of zero elements in a
compound initialiser caused pr34856 to trigger on powerpc*-darwin:

    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34856
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49987

The problem is the same as it was on i386 and spu: the backend can
create CONST_VECTORs with symbolic elements, which in the 34856 trail
above was decided to be invalid.  Although a patch was written for
powerpc at the same time, the problem apparently didn't trigger on
powerpc targets until after my patch.

Tested by Dominique on powerpc-apple-darwin9.8.0 (thanks).  OK to install?

Richard


gcc/
	PR target/49987
	* config/rs6000/rs6000.c (paired_expand_vector_init): Check for
	valid CONST_VECTOR operands.
	(rs6000_expand_vector_init): Likewise.
Mike Stump - Aug. 23, 2011, 5:35 p.m.
On Aug 23, 2011, at 3:44 AM, Richard Sandiford wrote:
> My patches to more "accurately" detect the number of zero elements in a
> compound initialiser caused pr34856 to trigger on powerpc*-darwin:
> 
>    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34856

Thanks for fixing this...  I don't think that is darwin code, so I can't approve it...

Patch

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	2011-08-18 13:37:31.395814534 +0100
+++ gcc/config/rs6000/rs6000.c	2011-08-23 11:35:07.417677742 +0100
@@ -4503,7 +4503,9 @@  paired_expand_vector_init (rtx target, r
   for (i = 0; i < n_elts; ++i)
     {
       x = XVECEXP (vals, 0, i);
-      if (!CONSTANT_P (x))
+      if (!(CONST_INT_P (x)
+	    || GET_CODE (x) == CONST_DOUBLE
+	    || GET_CODE (x) == CONST_FIXED))
 	++n_var;
     }
   if (n_var == 0)
@@ -4655,7 +4657,9 @@  rs6000_expand_vector_init (rtx target, r
   for (i = 0; i < n_elts; ++i)
     {
       x = XVECEXP (vals, 0, i);
-      if (!CONSTANT_P (x))
+      if (!(CONST_INT_P (x)
+	    || GET_CODE (x) == CONST_DOUBLE
+	    || GET_CODE (x) == CONST_FIXED))
 	++n_var, one_var = i;
       else if (x != CONST0_RTX (inner_mode))
 	all_const_zero = false;