2013-10-02 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. Index: ipa-inline-analysis.c =================================================================== --- ipa-inline-analysis.c (revision 203137) +++ ipa-inline-analysis.c (working copy) @@ -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 * } } + 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 * 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, " ");