diff mbox

PR54915 (ssa-forwprop, vec_perm_expr)

Message ID alpine.DEB.2.02.1210131123460.16300@stedding.saclay.inria.fr
State New
Headers show

Commit Message

Marc Glisse Oct. 13, 2012, 9:25 a.m. UTC
On Fri, 12 Oct 2012, Marc Glisse wrote:

> Hello,
>
> apparently, in the optimization that recognizes that {v[1],v[0]} is a 
> VEC_PERM_EXPR, I forgot to check that v is a 2-element vector... (not that 
> there aren't things that could be done if v has a different size, just not 
> directly a VEC_PERM_EXPR, and not right now, priority is to fix the bug)
>
> Checking that v has the same type as the result seemed like the easiest way, 
> but there are many variations that could be slightly better or worse.
>
> bootstrap+testsuite ok.
>
> 2012-10-02  Marc Glisse  <marc.glisse@inria.fr>
>
> 	PR tree-optimization/54915
>
> gcc/
> 	* tree-ssa-forwprop.c (simplify_vector_constructor): Check
> 	argument's type.
>
> gcc/testsuite/
> 	* gcc.dg/tree-ssa/pr54915.c: New testcase.

This new version, with a slightly relaxed test, seems preferable and also 
passes testing.

Comments

Richard Biener Oct. 15, 2012, 8:43 a.m. UTC | #1
On Sat, Oct 13, 2012 at 11:25 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Fri, 12 Oct 2012, Marc Glisse wrote:
>
>> Hello,
>>
>> apparently, in the optimization that recognizes that {v[1],v[0]} is a
>> VEC_PERM_EXPR, I forgot to check that v is a 2-element vector... (not that
>> there aren't things that could be done if v has a different size, just not
>> directly a VEC_PERM_EXPR, and not right now, priority is to fix the bug)
>>
>> Checking that v has the same type as the result seemed like the easiest
>> way, but there are many variations that could be slightly better or worse.
>>
>> bootstrap+testsuite ok.
>>
>> 2012-10-02  Marc Glisse  <marc.glisse@inria.fr>
>>
>>         PR tree-optimization/54915
>>
>> gcc/
>>         * tree-ssa-forwprop.c (simplify_vector_constructor): Check
>>         argument's type.
>>
>> gcc/testsuite/
>>         * gcc.dg/tree-ssa/pr54915.c: New testcase.
>
>
> This new version, with a slightly relaxed test, seems preferable and also
> passes testing.

Ok.

Thanks,
Richard.

> --
> Marc Glisse
> Index: testsuite/gcc.dg/tree-ssa/pr54915.c
> ===================================================================
> --- testsuite/gcc.dg/tree-ssa/pr54915.c (revision 0)
> +++ testsuite/gcc.dg/tree-ssa/pr54915.c (revision 0)
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +typedef double v2df __attribute__ ((__vector_size__ (16)));
> +typedef double v4df __attribute__ ((__vector_size__ (32)));
> +
> +void f (v2df *ret, v4df* xp)
> +{
> +  v4df x = *xp;
> +  v2df xx = { x[2], x[3] };
> +  *ret = xx;
> +}
>
> Property changes on: testsuite/gcc.dg/tree-ssa/pr54915.c
> ___________________________________________________________________
> Added: svn:eol-style
>    + native
> Added: svn:keywords
>    + Author Date Id Revision URL
>
> Index: tree-ssa-forwprop.c
> ===================================================================
> --- tree-ssa-forwprop.c (revision 192420)
> +++ tree-ssa-forwprop.c (working copy)
> @@ -2833,20 +2833,22 @@ simplify_vector_constructor (gimple_stmt
>        ref = TREE_OPERAND (op1, 0);
>        if (orig)
>         {
>           if (ref != orig)
>             return false;
>         }
>        else
>         {
>           if (TREE_CODE (ref) != SSA_NAME)
>             return false;
> +         if (!useless_type_conversion_p (type, TREE_TYPE (ref)))
> +           return false;
>           orig = ref;
>         }
>        if (TREE_INT_CST_LOW (TREE_OPERAND (op1, 1)) != elem_size)
>         return false;
>        sel[i] = TREE_INT_CST_LOW (TREE_OPERAND (op1, 2)) / elem_size;
>        if (sel[i] != i) maybe_ident = false;
>      }
>    if (i < nelts)
>      return false;
>
>
diff mbox

Patch

Index: testsuite/gcc.dg/tree-ssa/pr54915.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/pr54915.c	(revision 0)
+++ testsuite/gcc.dg/tree-ssa/pr54915.c	(revision 0)
@@ -0,0 +1,12 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef double v2df __attribute__ ((__vector_size__ (16)));
+typedef double v4df __attribute__ ((__vector_size__ (32)));
+
+void f (v2df *ret, v4df* xp)
+{
+  v4df x = *xp;
+  v2df xx = { x[2], x[3] };
+  *ret = xx;
+}

Property changes on: testsuite/gcc.dg/tree-ssa/pr54915.c
___________________________________________________________________
Added: svn:eol-style
   + native
Added: svn:keywords
   + Author Date Id Revision URL

Index: tree-ssa-forwprop.c
===================================================================
--- tree-ssa-forwprop.c	(revision 192420)
+++ tree-ssa-forwprop.c	(working copy)
@@ -2833,20 +2833,22 @@  simplify_vector_constructor (gimple_stmt
       ref = TREE_OPERAND (op1, 0);
       if (orig)
 	{
 	  if (ref != orig)
 	    return false;
 	}
       else
 	{
 	  if (TREE_CODE (ref) != SSA_NAME)
 	    return false;
+	  if (!useless_type_conversion_p (type, TREE_TYPE (ref)))
+	    return false;
 	  orig = ref;
 	}
       if (TREE_INT_CST_LOW (TREE_OPERAND (op1, 1)) != elem_size)
 	return false;
       sel[i] = TREE_INT_CST_LOW (TREE_OPERAND (op1, 2)) / elem_size;
       if (sel[i] != i) maybe_ident = false;
     }
   if (i < nelts)
     return false;