From: Jakub Jelinek Date: Sat, 9 Nov 2019 17:09:44 +0000 (+0100) Subject: re PR tree-optimization/92401 (ICE in fold_ternary_loc, at fold-const.c:11698) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c47bee97fa9927563a5015b28e24a5505ba557a3;p=gcc.git re PR tree-optimization/92401 (ICE in fold_ternary_loc, at fold-const.c:11698) PR tree-optimization/92401 * gimple-match-head.c (gimple_resimplify1): Call const_unop only if res_op->code is an expression with code length 1. * gimple-match-head.c (gimple_resimplify2): Call const_binop only if res_op->code is an expression with code length 2. * gimple-match-head.c (gimple_resimplify3): Call fold_ternary only if res_op->code is an expression with code length 3. * g++.dg/opt/pr92401.C: New test. From-SVN: r278004 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f82006ac08b..d0fe87e3267 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2019-11-09 Jakub Jelinek + + PR tree-optimization/92401 + * gimple-match-head.c (gimple_resimplify1): Call const_unop only + if res_op->code is an expression with code length 1. + * gimple-match-head.c (gimple_resimplify2): Call const_binop only + if res_op->code is an expression with code length 2. + * gimple-match-head.c (gimple_resimplify3): Call fold_ternary only + if res_op->code is an expression with code length 3. + 2019-11-09 Iain Sandoe * config/darwin.c (machopic_mcount_stub_name): Validate the diff --git a/gcc/gimple-match-head.c b/gcc/gimple-match-head.c index d7c74a1865a..2996bade301 100644 --- a/gcc/gimple-match-head.c +++ b/gcc/gimple-match-head.c @@ -191,7 +191,12 @@ gimple_resimplify1 (gimple_seq *seq, gimple_match_op *res_op, { tree tem = NULL_TREE; if (res_op->code.is_tree_code ()) - tem = const_unop (res_op->code, res_op->type, res_op->ops[0]); + { + tree_code code = res_op->code; + if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)) + && TREE_CODE_LENGTH (code) == 1) + tem = const_unop (res_op->code, res_op->type, res_op->ops[0]); + } else tem = fold_const_call (combined_fn (res_op->code), res_op->type, res_op->ops[0]); @@ -252,8 +257,13 @@ gimple_resimplify2 (gimple_seq *seq, gimple_match_op *res_op, { tree tem = NULL_TREE; if (res_op->code.is_tree_code ()) - tem = const_binop (res_op->code, res_op->type, - res_op->ops[0], res_op->ops[1]); + { + tree_code code = res_op->code; + if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)) + && TREE_CODE_LENGTH (code) == 2) + tem = const_binop (res_op->code, res_op->type, + res_op->ops[0], res_op->ops[1]); + } else tem = fold_const_call (combined_fn (res_op->code), res_op->type, res_op->ops[0], res_op->ops[1]); @@ -325,9 +335,14 @@ gimple_resimplify3 (gimple_seq *seq, gimple_match_op *res_op, { tree tem = NULL_TREE; if (res_op->code.is_tree_code ()) - tem = fold_ternary/*_to_constant*/ (res_op->code, res_op->type, - res_op->ops[0], res_op->ops[1], - res_op->ops[2]); + { + tree_code code = res_op->code; + if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)) + && TREE_CODE_LENGTH (code) == 3) + tem = fold_ternary/*_to_constant*/ (res_op->code, res_op->type, + res_op->ops[0], res_op->ops[1], + res_op->ops[2]); + } else tem = fold_const_call (combined_fn (res_op->code), res_op->type, res_op->ops[0], res_op->ops[1], res_op->ops[2]); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0f8ef38320e..fcad98053bc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-09 Jakub Jelinek + + PR tree-optimization/92401 + * g++.dg/opt/pr92401.C: New test. + 2019-11-09 Thomas Koenig PR fortran/92321 diff --git a/gcc/testsuite/g++.dg/opt/pr92401.C b/gcc/testsuite/g++.dg/opt/pr92401.C new file mode 100644 index 00000000000..fda9821279d --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr92401.C @@ -0,0 +1,15 @@ +// PR tree-optimization/92401 +// { dg-do compile { target c++11 } } +// { dg-options "-O2" } + +typedef float V __attribute__ ((__vector_size__ (4 * sizeof (float)))); + +V v; + +void +foo () +{ + int i; + for (i = 0; i < 11; ++i) + v = V { 0.0f, 0.0f, (float) i, 0.0f }; +}