diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5ffb64ff05..f6c57ff0b98 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2013-10-03 Rong Xu + + * ipa-inline-analysis.c (find_foldable_builtin_expect): Find + the candidate of builtin_expect such that we should fix the + size/time estimation. + (estimate_function_body_sizes): Do the acutally size/time fix-up + for builtin_expect. + 2013-10-03 Rong Xu * predict.c (tree_predict_by_opcode): Get the probability diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index 7ca09ad0b91..304f9f5d7cc 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -2257,6 +2257,77 @@ array_index_predicate (struct inline_summary *info, return p; } +/* For a typical usage of __builtin_expect (aconds = NULL; info->entry = NULL; @@ -2360,6 +2432,8 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) } } + fix_builtin_expect_stmt = find_foldable_builtin_expect (bb); + for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); @@ -2368,6 +2442,14 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) int prob; struct predicate will_be_nonconstant; + /* This relation stmt should be folded after we remove + buildin_expect call. Adjust the cost here. */ + if (stmt == fix_builtin_expect_stmt) + { + this_size--; + this_time--; + } + if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, " ");