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]

Re: [PATCH] Fix PR57980


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.

Thanks,
Richard.

>2013-08-09  Marek Polacek  <polacek@redhat.com>
>	    Marc Glisse  <marc.glisse@inria.fr>
>
>	PR tree-optimization/57980
>	* tree-tailcall.c (process_assignment): Call build_minus_one_cst
>	when creating -1 constant.
>
>	* gcc.dg/pr57980.c: New test.
>
>--- gcc/tree-tailcall.c.mp	2013-08-09 16:07:55.778616996 +0200
>+++ gcc/tree-tailcall.c	2013-08-09 16:08:00.068635823 +0200
>@@ -326,11 +326,7 @@ process_assignment (gimple stmt, gimple_
>       return true;
> 
>     case NEGATE_EXPR:
>-      if (FLOAT_TYPE_P (TREE_TYPE (op0)))
>-        *m = build_real (TREE_TYPE (op0), dconstm1);
>-      else
>-        *m = build_int_cst (TREE_TYPE (op0), -1);
>-
>+      *m = build_minus_one_cst (TREE_TYPE (op0));
>       *ass_var = dest;
>       return true;
> 
>@@ -339,11 +335,7 @@ process_assignment (gimple stmt, gimple_
>  *a = fold_build1 (NEGATE_EXPR, TREE_TYPE (non_ass_var), non_ass_var);
>       else
>         {
>-          if (FLOAT_TYPE_P (TREE_TYPE (non_ass_var)))
>-            *m = build_real (TREE_TYPE (non_ass_var), dconstm1);
>-          else
>-            *m = build_int_cst (TREE_TYPE (non_ass_var), -1);
>-
>+	  *m = build_minus_one_cst (TREE_TYPE (non_ass_var));
>  *a = fold_build1 (NEGATE_EXPR, TREE_TYPE (non_ass_var), non_ass_var);
>         }
> 
>--- gcc/testsuite/gcc.dg/pr57980.c.mp	2013-08-09 16:07:25.967485356
>+0200
>+++ gcc/testsuite/gcc.dg/pr57980.c	2013-08-09 16:07:17.967450526 +0200
>@@ -0,0 +1,19 @@
>+/* PR tree-optimization/57980 */
>+/* { dg-do compile } */
>+/* { dg-options "-O -foptimize-sibling-calls" } */
>+
>+typedef int V __attribute__ ((vector_size (sizeof (int))));
>+extern V f (void);
>+
>+V
>+bar (void)
>+{
>+  return -f ();
>+}
>+
>+V
>+foo (void)
>+{
>+  V v = { };
>+  return v - f ();
>+}
>
>	Marek



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