Commit ce120587 by Jan Hubicka Committed by Jan Hubicka

gimple.c: Include builtins.h


	* gimple.c: Include builtins.h
	(gimple_inexpensive_call_p): New function.
	* gimple.h (gimple_inexpensive_call_p): Declare.
	* tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Use it.
	* tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Likewise;
	fix formatting.

From-SVN: r237172
parent 701b9a47
2016-06-07 Jan Hubicka <hubicka@ucw.cz>
* gimple.c: Include builtins.h
(gimple_inexpensive_call_p): New function.
* gimple.h (gimple_inexpensive_call_p): Declare.
* tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Use it.
* tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Likewise;
fix formatting.
2016-06-07 Paolo Carlini <paolo.carlini@oracle.com> 2016-06-07 Paolo Carlini <paolo.carlini@oracle.com>
* diagnostic.c (diagnostic_impl, diagnostic_n_impl): New. * diagnostic.c (diagnostic_impl, diagnostic_n_impl): New.
......
...@@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-walk.h" #include "gimple-walk.h"
#include "gimplify.h" #include "gimplify.h"
#include "target.h" #include "target.h"
#include "builtins.h"
#include "selftest.h" #include "selftest.h"
#include "gimple-pretty-print.h" #include "gimple-pretty-print.h"
...@@ -3025,6 +3026,19 @@ maybe_remove_unused_call_args (struct function *fn, gimple *stmt) ...@@ -3025,6 +3026,19 @@ maybe_remove_unused_call_args (struct function *fn, gimple *stmt)
} }
} }
/* Return false if STMT will likely expand to real function call. */
bool
gimple_inexpensive_call_p (gcall *stmt)
{
if (gimple_call_internal_p (stmt))
return true;
tree decl = gimple_call_fndecl (stmt);
if (decl && is_inexpensive_builtin (decl))
return true;
return false;
}
#if CHECKING_P #if CHECKING_P
namespace selftest { namespace selftest {
......
...@@ -1525,6 +1525,7 @@ extern void preprocess_case_label_vec_for_gimple (vec<tree>, tree, tree *); ...@@ -1525,6 +1525,7 @@ extern void preprocess_case_label_vec_for_gimple (vec<tree>, tree, tree *);
extern void gimple_seq_set_location (gimple_seq, location_t); extern void gimple_seq_set_location (gimple_seq, location_t);
extern void gimple_seq_discard (gimple_seq); extern void gimple_seq_discard (gimple_seq);
extern void maybe_remove_unused_call_args (struct function *, gimple *); extern void maybe_remove_unused_call_args (struct function *, gimple *);
extern bool gimple_inexpensive_call_p (gcall *);
/* Formal (expression) temporary table handling: multiple occurrences of /* Formal (expression) temporary table handling: multiple occurrences of
the same scalar expression are evaluated into the same temporary. */ the same scalar expression are evaluated into the same temporary. */
......
...@@ -118,7 +118,8 @@ should_duplicate_loop_header_p (basic_block header, struct loop *loop, ...@@ -118,7 +118,8 @@ should_duplicate_loop_header_p (basic_block header, struct loop *loop,
if (is_gimple_debug (last)) if (is_gimple_debug (last))
continue; continue;
if (is_gimple_call (last)) if (gimple_code (last) == GIMPLE_CALL
&& !gimple_inexpensive_call_p (as_a <gcall *> (last)))
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, fprintf (dump_file,
......
...@@ -207,8 +207,8 @@ constant_after_peeling (tree op, gimple *stmt, struct loop *loop) ...@@ -207,8 +207,8 @@ constant_after_peeling (tree op, gimple *stmt, struct loop *loop)
Stop estimating after UPPER_BOUND is met. Return true in this case. */ Stop estimating after UPPER_BOUND is met. Return true in this case. */
static bool static bool
tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, struct loop_size *size, tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel,
int upper_bound) struct loop_size *size, int upper_bound)
{ {
basic_block *body = get_loop_body (loop); basic_block *body = get_loop_body (loop);
gimple_stmt_iterator gsi; gimple_stmt_iterator gsi;
...@@ -236,7 +236,8 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru ...@@ -236,7 +236,8 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru
else else
after_exit = false; after_exit = false;
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, " BB: %i, after_exit: %i\n", body[i]->index, after_exit); fprintf (dump_file, " BB: %i, after_exit: %i\n", body[i]->index,
after_exit);
for (gsi = gsi_start_bb (body[i]); !gsi_end_p (gsi); gsi_next (&gsi)) for (gsi = gsi_start_bb (body[i]); !gsi_end_p (gsi); gsi_next (&gsi))
{ {
...@@ -285,20 +286,24 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru ...@@ -285,20 +286,24 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru
/* Assignments of IV variables. */ /* Assignments of IV variables. */
else if (gimple_code (stmt) == GIMPLE_ASSIGN else if (gimple_code (stmt) == GIMPLE_ASSIGN
&& TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME && TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME
&& constant_after_peeling (gimple_assign_rhs1 (stmt), stmt, loop) && constant_after_peeling (gimple_assign_rhs1 (stmt), stmt,
loop)
&& (gimple_assign_rhs_class (stmt) != GIMPLE_BINARY_RHS && (gimple_assign_rhs_class (stmt) != GIMPLE_BINARY_RHS
|| constant_after_peeling (gimple_assign_rhs2 (stmt), || constant_after_peeling (gimple_assign_rhs2 (stmt),
stmt, loop))) stmt, loop)))
{ {
size->constant_iv = true; size->constant_iv = true;
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, " Constant expression will be folded away.\n"); fprintf (dump_file,
" Constant expression will be folded away.\n");
likely_eliminated = true; likely_eliminated = true;
} }
/* Conditionals. */ /* Conditionals. */
else if ((gimple_code (stmt) == GIMPLE_COND else if ((gimple_code (stmt) == GIMPLE_COND
&& constant_after_peeling (gimple_cond_lhs (stmt), stmt, loop) && constant_after_peeling (gimple_cond_lhs (stmt), stmt,
&& constant_after_peeling (gimple_cond_rhs (stmt), stmt, loop) loop)
&& constant_after_peeling (gimple_cond_rhs (stmt), stmt,
loop)
/* We don't simplify all constant compares so make sure /* We don't simplify all constant compares so make sure
they are not both constant already. See PR70288. */ they are not both constant already. See PR70288. */
&& (! is_gimple_min_invariant (gimple_cond_lhs (stmt)) && (! is_gimple_min_invariant (gimple_cond_lhs (stmt))
...@@ -307,8 +312,8 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru ...@@ -307,8 +312,8 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru
&& constant_after_peeling (gimple_switch_index ( && constant_after_peeling (gimple_switch_index (
as_a <gswitch *> (stmt)), as_a <gswitch *> (stmt)),
stmt, loop) stmt, loop)
&& ! is_gimple_min_invariant (gimple_switch_index ( && ! is_gimple_min_invariant
as_a <gswitch *> (stmt))))) (gimple_switch_index (as_a <gswitch *> (stmt)))))
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, " Constant conditional.\n"); fprintf (dump_file, " Constant conditional.\n");
...@@ -339,26 +344,24 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru ...@@ -339,26 +344,24 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{ {
gimple *stmt = gsi_stmt (gsi); gimple *stmt = gsi_stmt (gsi);
if (gimple_code (stmt) == GIMPLE_CALL) if (gimple_code (stmt) == GIMPLE_CALL
&& !gimple_inexpensive_call_p (as_a <gcall *> (stmt)))
{ {
int flags = gimple_call_flags (stmt); int flags = gimple_call_flags (stmt);
tree decl = gimple_call_fndecl (stmt); if (flags & (ECF_PURE | ECF_CONST))
if (decl && DECL_IS_BUILTIN (decl)
&& is_inexpensive_builtin (decl))
;
else if (flags & (ECF_PURE | ECF_CONST))
size->num_pure_calls_on_hot_path++; size->num_pure_calls_on_hot_path++;
else else
size->num_non_pure_calls_on_hot_path++; size->num_non_pure_calls_on_hot_path++;
size->num_branches_on_hot_path ++; size->num_branches_on_hot_path ++;
} }
else if (gimple_code (stmt) != GIMPLE_CALL /* Count inexpensive calls as non-calls, because they will likely
&& gimple_code (stmt) != GIMPLE_DEBUG) expand inline. */
else if (gimple_code (stmt) != GIMPLE_DEBUG)
size->non_call_stmts_on_hot_path++; size->non_call_stmts_on_hot_path++;
if (((gimple_code (stmt) == GIMPLE_COND if (((gimple_code (stmt) == GIMPLE_COND
&& (!constant_after_peeling (gimple_cond_lhs (stmt), stmt, loop) && (!constant_after_peeling (gimple_cond_lhs (stmt), stmt, loop)
|| constant_after_peeling (gimple_cond_rhs (stmt), stmt, loop))) || constant_after_peeling (gimple_cond_rhs (stmt), stmt,
loop)))
|| (gimple_code (stmt) == GIMPLE_SWITCH || (gimple_code (stmt) == GIMPLE_SWITCH
&& !constant_after_peeling (gimple_switch_index ( && !constant_after_peeling (gimple_switch_index (
as_a <gswitch *> (stmt)), as_a <gswitch *> (stmt)),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment