Committed. Richard.
2014-03-13 Richard Biener <rguent...@suse.de> * gimple-match-head.c (gimple_resimplify2, gimple_resimplify3): Implement missing call handling. (gimple_match_and_simplify): Fix lhs gathering. Index: gcc/gimple-match-head.c =================================================================== *** gcc/gimple-match-head.c (revision 208482) --- gcc/gimple-match-head.c (working copy) *************** gimple_resimplify2 (gimple_seq *seq, *** 121,133 **** code_helper *res_code, tree type, tree *res_ops, tree (*valueize)(tree)) { - /* FIXME. */ - if (!res_code->is_tree_code ()) - gcc_unreachable (); if (CONSTANT_CLASS_P (res_ops[0]) && CONSTANT_CLASS_P (res_ops[1])) { ! tree tem = fold_binary_to_constant (*res_code, type, ! res_ops[0], res_ops[1]); if (tem != NULL_TREE) { res_ops[0] = tem; --- 121,137 ---- code_helper *res_code, tree type, tree *res_ops, tree (*valueize)(tree)) { if (CONSTANT_CLASS_P (res_ops[0]) && CONSTANT_CLASS_P (res_ops[1])) { ! tree tem; ! if (res_code->is_tree_code ()) ! tem = fold_binary_to_constant (*res_code, type, ! res_ops[0], res_ops[1]); ! else ! { ! tree decl = builtin_decl_implicit (*res_code); ! tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 2, false); ! } if (tem != NULL_TREE) { res_ops[0] = tem; *************** gimple_resimplify2 (gimple_seq *seq, *** 137,143 **** } /* Canonicalize operand order. */ ! if (commutative_tree_code (*res_code) && tree_swap_operands_p (res_ops[0], res_ops[1], false)) { tree tem = res_ops[0]; --- 141,148 ---- } /* Canonicalize operand order. */ ! if (res_code->is_tree_code () ! && commutative_tree_code (*res_code) && tree_swap_operands_p (res_ops[0], res_ops[1], false)) { tree tem = res_ops[0]; *************** gimple_resimplify3 (gimple_seq *seq, *** 168,181 **** code_helper *res_code, tree type, tree *res_ops, tree (*valueize)(tree)) { - /* FIXME. */ - if (!res_code->is_tree_code ()) - gcc_unreachable (); if (CONSTANT_CLASS_P (res_ops[0]) && CONSTANT_CLASS_P (res_ops[1]) && CONSTANT_CLASS_P (res_ops[2])) { ! tree tem = fold_ternary/*_to_constant*/ (*res_code, type, res_ops[0], ! res_ops[1], res_ops[2]); if (tem != NULL_TREE && CONSTANT_CLASS_P (tem)) { --- 173,190 ---- code_helper *res_code, tree type, tree *res_ops, tree (*valueize)(tree)) { if (CONSTANT_CLASS_P (res_ops[0]) && CONSTANT_CLASS_P (res_ops[1]) && CONSTANT_CLASS_P (res_ops[2])) { ! tree tem; ! if (res_code->is_tree_code ()) ! tem = fold_ternary/*_to_constant*/ (*res_code, type, res_ops[0], ! res_ops[1], res_ops[2]); ! else ! { ! tree decl = builtin_decl_implicit (*res_code); ! tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 3, false); ! } if (tem != NULL_TREE && CONSTANT_CLASS_P (tem)) { *************** gimple_resimplify3 (gimple_seq *seq, *** 186,192 **** } /* Canonicalize operand order. */ ! if (commutative_ternary_tree_code (*res_code) && tree_swap_operands_p (res_ops[0], res_ops[1], false)) { tree tem = res_ops[0]; --- 195,202 ---- } /* Canonicalize operand order. */ ! if (res_code->is_tree_code () ! && commutative_ternary_tree_code (*res_code) && tree_swap_operands_p (res_ops[0], res_ops[1], false)) { tree tem = res_ops[0]; *************** gimple_match_and_simplify (gimple stmt, *** 483,490 **** } } - /* ??? GIMPLE_CALL handling to be implemented. */ - return false; } --- 493,498 ---- *************** gimple_match_and_simplify (gimple_stmt_i *** 532,538 **** else if (gimple_has_lhs (stmt)) { gimple_seq tail = NULL; ! tree lhs = gimple_call_lhs (stmt); maybe_push_res_to_seq (rcode, TREE_TYPE (lhs), ops, &tail, lhs); gcc_assert (gimple_seq_singleton_p (tail)); --- 540,546 ---- else if (gimple_has_lhs (stmt)) { gimple_seq tail = NULL; ! tree lhs = gimple_get_lhs (stmt); maybe_push_res_to_seq (rcode, TREE_TYPE (lhs), ops, &tail, lhs); gcc_assert (gimple_seq_singleton_p (tail));