https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92401
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I guess one way to fix this would be: --- gcc/gimple-match-head.c.jj 2019-11-01 22:19:49.604831956 +0100 +++ gcc/gimple-match-head.c 2019-11-07 17:40:32.799882669 +0100 @@ -191,7 +191,11 @@ gimple_resimplify1 (gimple_seq *seq, gim { tree tem = NULL_TREE; if (res_op->code.is_tree_code ()) - tem = const_unop (res_op->code, res_op->type, res_op->ops[0]); + { + if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (res_op->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 +256,12 @@ gimple_resimplify2 (gimple_seq *seq, gim { 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]); + { + if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (res_op->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 +333,13 @@ gimple_resimplify3 (gimple_seq *seq, gim { 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]); + { + if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (res_op->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]); const_unop/const_binop are actually quite forgiving on what they are called with, just return NULL_TREE, but fold_ternary is not. res_op->code in this case is a CONSTRUCTOR with 3 elts.