re PR middle-end/70307 (ICE: in gimplify_expr, at gimplify.c:10915 on valid code)

PR c/70307
	* c-fold.c (c_fully_fold_internal): Handle VEC_COND_EXPR.

	* gcc.dg/torture/pr70307.c: New test.

From-SVN: r234706
This commit is contained in:
Marek Polacek 2016-04-04 08:11:46 +00:00 committed by Marek Polacek
parent dbc3f12558
commit f13355da30
4 changed files with 92 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2016-04-04 Marek Polacek <polacek@redhat.com>
PR c/70307
* c-fold.c (c_fully_fold_internal): Handle VEC_COND_EXPR.
2016-03-31 Marek Polacek <polacek@redhat.com>
PR c/70297

View File

@ -528,6 +528,26 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
*maybe_const_itself &= op2_const_self;
goto out;
case VEC_COND_EXPR:
orig_op0 = op0 = TREE_OPERAND (expr, 0);
orig_op1 = op1 = TREE_OPERAND (expr, 1);
orig_op2 = op2 = TREE_OPERAND (expr, 2);
op0 = c_fully_fold_internal (op0, in_init, maybe_const_operands,
maybe_const_itself, for_int_const);
STRIP_TYPE_NOPS (op0);
op1 = c_fully_fold_internal (op1, in_init, maybe_const_operands,
maybe_const_itself, for_int_const);
STRIP_TYPE_NOPS (op1);
op2 = c_fully_fold_internal (op2, in_init, maybe_const_operands,
maybe_const_itself, for_int_const);
STRIP_TYPE_NOPS (op2);
if (op0 != orig_op0 || op1 != orig_op1 || op2 != orig_op2)
ret = fold_build3_loc (loc, code, TREE_TYPE (expr), op0, op1, op2);
else
ret = fold (expr);
goto out;
case EXCESS_PRECISION_EXPR:
/* Each case where an operand with excess precision may be
encountered must remove the EXCESS_PRECISION_EXPR around

View File

@ -1,3 +1,8 @@
2016-04-04 Marek Polacek <polacek@redhat.com>
PR c/70307
* gcc.dg/torture/pr70307.c: New test.
2016-04-03 Oleg Endo <olegendo@gcc.gnu.org>
PR target/70416

View File

@ -0,0 +1,62 @@
/* PR c/70307 */
/* { dg-do compile } */
typedef int v4si __attribute__ ((vector_size (16)));
v4si foo (v4si);
v4si
fn1 (int i)
{
return i <= (v4si){(0, 0)};
}
v4si
fn2 (int i)
{
v4si r;
r = i <= (v4si){(0, 0)};
return r;
}
v4si
fn3 (int i)
{
return foo (i <= (v4si){(0, 0)});
}
v4si
fn4 (int i)
{
struct S { v4si v; };
struct S s = { .v = i <= (v4si){(0, 0)} };
return s.v;
}
v4si
fn5 (int i)
{
return (v4si){(1, i++)} == (v4si){(0, 0)};
}
v4si
fn6 (int i)
{
v4si r;
r = (v4si){(1, i++)} == (v4si){(0, 0)};
return r;
}
v4si
fn7 (int i)
{
return foo ((v4si){(1, i++)} == (v4si){(0, 0)});
}
v4si
fn8 (int i)
{
struct S { v4si v; };
struct S s = { .v = (v4si){(1, i++)} == (v4si){(0, 0)} };
return s.v;
}