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] more simplify_subreg SIMD bugs


More simplify_subreg brokenness. This one shows up with funky unions.

Consider a call to simplify_subreg() with OP being a CONST_VECTOR:V2SI, where INNERMODE is V2SI and OUTERMODE is V2SF.

simplify_subreg will do:

  /* Simplify subregs of vector constants.  */
  if (GET_CODE (op) == CONST_VECTOR)
    {
	   ...
>>	   /* All the tests in here will fail.  */
	   ...
	}
  /* Attempt to simplify constant to non-SUBREG expression.  */
  if (CONSTANT_P (op))
    {
	  ...
      if (VECTOR_MODE_P (outermode))
        {
          /* Construct a CONST_VECTOR from individual subregs.  */

Right up here ^^^^^^ we will try to construct a CONST_VECTOR from the individual subregs. The code assumes OP is a constant, but it doesn't take into account that a CONST_VECTOR is also a constant. So, we'll end up creating garbage.

We *could* do:

	if (CONSTANT_P (op) && !VECTOR_MODE_P (innermode))
	   etc

...but then we'd fall through to all the code below that which we know will not apply anyhow. So... the included patch just bails when we know we can't do anything else.

Tests pending on x86.

OK?

2003-06-13 Aldy Hernandez <aldyh@redhat.com>

	* simplify-rtx.c (simplify_subreg): Do not simplify constant to
	non-SUBREG if constant is a vector.

Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.142
diff -c -p -r1.142 simplify-rtx.c
*** simplify-rtx.c	13 Jun 2003 19:27:27 -0000	1.142
--- simplify-rtx.c	13 Jun 2003 19:38:59 -0000
*************** simplify_subreg (outermode, op, innermod
*** 2716,2721 ****
--- 2716,2725 ----
  	  rtvec v = rtvec_alloc (elts);
  	  rtx elt;

+ /* Eech, we can't really do much more past here. */
+ if (VECTOR_MODE_P (innermode))
+ return NULL_RTX;
+
for (i = 0; i < elts; i++, byte += subsize)
{
/* This might fail, e.g. if taking a subreg from a SYMBOL_REF. */



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