[backport proposed and approved but not yet applied patch for PR57980, depends on build_minus_one_cst backport ] List-Archive: Date: Fri, 9 Aug 2013 16:35:18 +0200 From: Marek Polacek Subject: [PATCH] Fix PR57980 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? 2013-08-09 Marek Polacek Marc Glisse 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-4.7.3/gcc/testsuite/gcc.dg/pr57980.c.~1~ 1970-01-01 01:00:00.000000000 +0100 +++ gcc-4.7.3/gcc/testsuite/gcc.dg/pr57980.c 2013-08-10 12:42:04.410899371 +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 (); +} --- gcc-4.7.3/gcc/tree-tailcall.c.~1~ 2013-04-03 10:22:12.000000000 +0200 +++ gcc-4.7.3/gcc/tree-tailcall.c 2013-08-10 12:42:04.410899371 +0200 @@ -327,11 +327,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; @@ -340,11 +336,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); }