Tailcalls have no argument setup cost and no return value cost. This patch adjusts estminate_num_insns to reflect that.
Honza, does this look correct? Bootstrapped and tested on x86_64-unknown-linux-gnu. Thanks, Richard. 2012-06-20 Richard Guenther <rguent...@suse.de> * tree-inline.c (estimate_num_insns): Estimate call cost for tailcalls properly. Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 188817) +++ gcc/tree-inline.c (working copy) @@ -3611,12 +3611,15 @@ estimate_num_insns (gimple stmt, eni_wei } cost = node ? weights->call_cost : weights->indirect_call_cost; - if (gimple_call_lhs (stmt)) - cost += estimate_move_cost (TREE_TYPE (gimple_call_lhs (stmt))); - for (i = 0; i < gimple_call_num_args (stmt); i++) + if (!gimple_call_tail_p (stmt)) { - tree arg = gimple_call_arg (stmt, i); - cost += estimate_move_cost (TREE_TYPE (arg)); + if (gimple_call_lhs (stmt)) + cost += estimate_move_cost (TREE_TYPE (gimple_call_lhs (stmt))); + for (i = 0; i < gimple_call_num_args (stmt); i++) + { + tree arg = gimple_call_arg (stmt, i); + cost += estimate_move_cost (TREE_TYPE (arg)); + } } break; }