diff mbox

Fix PR57980

Message ID 20130813115127.GO17022@redhat.com
State New
Headers show

Commit Message

Marek Polacek Aug. 13, 2013, 11:51 a.m. UTC
On Tue, Aug 13, 2013 at 12:24:59PM +0200, Jakub Jelinek wrote:
> On Mon, Aug 12, 2013 at 10:56:44AM +0200, Marek Polacek wrote:
> > On Fri, Aug 09, 2013 at 08:40:00PM +0200, Richard Biener wrote:
> > > Marek Polacek <polacek@redhat.com> wrote:
> > > >In this PR the problem was that when dealing with the gimple assign in
> > > >the tailcall optimization, we, when the rhs operand is of a vector
> > > >type, need to create -1 also of a vector type, but build_int_cst
> > > >doesn't create vectors (ICEs).  Instead, we should use
> > > >build_minus_one_cst
> > > >because that can create even the VECTOR_TYPE constant (and, it can
> > > >create even REAL_TYPE/COMPLEX_TYPE), as suggested by Marc.
> > > >
> > > >Regtested/bootstrapped on x86_64-linux, ok for trunk and 4.8?
> > > 
> > > Ok. Double-check that this function exists on the branch please.
> > 
> > It does not :(.  So not backporting to 4.8...
> 
> For 4.8/4.7, I'd say just change those
>   else
>     *m = build_int_cst (TREE_TYPE (...), -1);
> into
>   else if (INTEGRAL_TYPE_P (TREE_TYPE (...)))
>     *m = build_int_cst (TREE_TYPE (...), -1);
>   else
>     return false;

Sure.  Ok to apply this one if it passes regtesting?

2013-08-13  Marek Polacek  <polacek@redhat.com>
	    Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/57980
	* tree-tailcall.c (process_assignment): Return false
	when not dealing with integers or floats.

	* gcc.dg/pr57980.c: New test.


	Marek

Comments

Jakub Jelinek Aug. 13, 2013, 11:53 a.m. UTC | #1
On Tue, Aug 13, 2013 at 01:51:27PM +0200, Marek Polacek wrote:
> Sure.  Ok to apply this one if it passes regtesting?

Yes, thanks.

> 2013-08-13  Marek Polacek  <polacek@redhat.com>
> 	    Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/57980
> 	* tree-tailcall.c (process_assignment): Return false
> 	when not dealing with integers or floats.
> 
> 	* gcc.dg/pr57980.c: New test.
> 
> --- gcc/tree-tailcall.c.mp	2013-08-13 13:42:33.969568463 +0200
> +++ gcc/tree-tailcall.c	2013-08-13 13:44:57.288121663 +0200
> @@ -328,8 +328,10 @@ process_assignment (gimple stmt, gimple_
>      case NEGATE_EXPR:
>        if (FLOAT_TYPE_P (TREE_TYPE (op0)))
>          *m = build_real (TREE_TYPE (op0), dconstm1);
> -      else
> +      else if (INTEGRAL_TYPE_P (TREE_TYPE (op0)))
>          *m = build_int_cst (TREE_TYPE (op0), -1);
> +      else
> +        return false;
>  
>        *ass_var = dest;
>        return true;
> @@ -341,8 +343,10 @@ process_assignment (gimple stmt, gimple_
>          {
>            if (FLOAT_TYPE_P (TREE_TYPE (non_ass_var)))
>              *m = build_real (TREE_TYPE (non_ass_var), dconstm1);
> -          else
> +          else if (INTEGRAL_TYPE_P (TREE_TYPE (non_ass_var)))
>              *m = build_int_cst (TREE_TYPE (non_ass_var), -1);
> +	  else
> +	    return false;
>  
>            *a = fold_build1 (NEGATE_EXPR, TREE_TYPE (non_ass_var), non_ass_var);
>          }
> --- gcc/testsuite/gcc.dg/pr57980.c.mp	2013-08-13 13:41:55.216418468 +0200
> +++ gcc/testsuite/gcc.dg/pr57980.c	2013-08-13 13:41:33.116333703 +0200
> @@ -0,0 +1,19 @@
> +/* PR tree-optimization/57980 */
> +/* { dg-do compile } */
> +/* { dg-options "-O -foptimize-sibling-calls -w" } */
> +
> +typedef int V __attribute__ ((vector_size (2 * sizeof (int))));
> +extern V f (void);
> +
> +V
> +bar (void)
> +{
> +  return -f ();
> +}
> +
> +V
> +foo (void)
> +{
> +  V v = { };
> +  return v - f ();
> +}

	Jakub
diff mbox

Patch

--- gcc/tree-tailcall.c.mp	2013-08-13 13:42:33.969568463 +0200
+++ gcc/tree-tailcall.c	2013-08-13 13:44:57.288121663 +0200
@@ -328,8 +328,10 @@  process_assignment (gimple stmt, gimple_
     case NEGATE_EXPR:
       if (FLOAT_TYPE_P (TREE_TYPE (op0)))
         *m = build_real (TREE_TYPE (op0), dconstm1);
-      else
+      else if (INTEGRAL_TYPE_P (TREE_TYPE (op0)))
         *m = build_int_cst (TREE_TYPE (op0), -1);
+      else
+        return false;
 
       *ass_var = dest;
       return true;
@@ -341,8 +343,10 @@  process_assignment (gimple stmt, gimple_
         {
           if (FLOAT_TYPE_P (TREE_TYPE (non_ass_var)))
             *m = build_real (TREE_TYPE (non_ass_var), dconstm1);
-          else
+          else if (INTEGRAL_TYPE_P (TREE_TYPE (non_ass_var)))
             *m = build_int_cst (TREE_TYPE (non_ass_var), -1);
+	  else
+	    return false;
 
           *a = fold_build1 (NEGATE_EXPR, TREE_TYPE (non_ass_var), non_ass_var);
         }
--- gcc/testsuite/gcc.dg/pr57980.c.mp	2013-08-13 13:41:55.216418468 +0200
+++ gcc/testsuite/gcc.dg/pr57980.c	2013-08-13 13:41:33.116333703 +0200
@@ -0,0 +1,19 @@ 
+/* PR tree-optimization/57980 */
+/* { dg-do compile } */
+/* { dg-options "-O -foptimize-sibling-calls -w" } */
+
+typedef int V __attribute__ ((vector_size (2 * sizeof (int))));
+extern V f (void);
+
+V
+bar (void)
+{
+  return -f ();
+}
+
+V
+foo (void)
+{
+  V v = { };
+  return v - f ();
+}