Commit eb99f777 by Neil Vachharajani Committed by Neil Vachharajani

value-prof.c (interesting_stringop_to_profile_p): Added output argument to…

value-prof.c (interesting_stringop_to_profile_p): Added output argument to indicate which parameter is the size parameter.

2009-09-18  Neil Vachharajani  <nvachhar@google.com>

	    * value-prof.c (interesting_stringop_to_profile_p): Added output
	    argument to indicate which parameter is the size parameter.
	    * value-prof.c (gimple_stringop_fixed_value): Use
	    INTERESTING_STRINGOP_TO_PROFILE_P to find size argument.
	    * value-prof.c (gimple_stringops_transform): Update call sites to
	    INTERESTING_STRINGOP_TO_PROFILE_P to reflect parameter change.
	    * testsuite/gcc.dg/tree-prof/val-prof-7.c: Added test case.

From-SVN: r151864
parent 5eb8c44f
2009-09-18 Neil Vachharajani <nvachhar@google.com>
* value-prof.c (interesting_stringop_to_profile_p): Added output
argument to indicate which parameter is the size parameter.
* value-prof.c (gimple_stringop_fixed_value): Use
INTERESTING_STRINGOP_TO_PROFILE_P to find size argument.
* value-prof.c (gimple_stringops_transform): Update call sites to
INTERESTING_STRINGOP_TO_PROFILE_P to reflect parameter change.
* testsuite/gcc.dg/tree-prof/val-prof-7.c: Added test case.
2009-09-18 Uros Bizjak <ubizjak@gmail.com> 2009-09-18 Uros Bizjak <ubizjak@gmail.com>
PR target/38288 PR target/38288
......
/* { dg-options "-O2 -fdump-tree-tree_profile -mtune=core2" } */
/* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } { "*" } { "" } } */
#include <strings.h>
int foo(int len)
{
char array[1000];
bzero(array, len);
return 0;
}
int main() {
int i;
for (i = 0; i < 1000; i++)
{
if (i > 990)
foo(16);
else
foo(8);
}
return 0;
}
/* { dg-final-use { scan-tree-dump "Single value 8 stringop transformation on bzero" "tree_profile"} } */
/* { dg-final-use { cleanup-tree-dump "tree_profile" } } */
...@@ -1241,9 +1241,12 @@ gimple_ic_transform (gimple stmt) ...@@ -1241,9 +1241,12 @@ gimple_ic_transform (gimple stmt)
return true; return true;
} }
/* Return true if the stringop CALL with FNDECL shall be profiled. */ /* Return true if the stringop CALL with FNDECL shall be profiled.
SIZE_ARG be set to the argument index for the size of the string
operation.
*/
static bool static bool
interesting_stringop_to_profile_p (tree fndecl, gimple call) interesting_stringop_to_profile_p (tree fndecl, gimple call, int *size_arg)
{ {
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
...@@ -1255,12 +1258,15 @@ interesting_stringop_to_profile_p (tree fndecl, gimple call) ...@@ -1255,12 +1258,15 @@ interesting_stringop_to_profile_p (tree fndecl, gimple call)
{ {
case BUILT_IN_MEMCPY: case BUILT_IN_MEMCPY:
case BUILT_IN_MEMPCPY: case BUILT_IN_MEMPCPY:
*size_arg = 2;
return validate_gimple_arglist (call, POINTER_TYPE, POINTER_TYPE, return validate_gimple_arglist (call, POINTER_TYPE, POINTER_TYPE,
INTEGER_TYPE, VOID_TYPE); INTEGER_TYPE, VOID_TYPE);
case BUILT_IN_MEMSET: case BUILT_IN_MEMSET:
*size_arg = 2;
return validate_gimple_arglist (call, POINTER_TYPE, INTEGER_TYPE, return validate_gimple_arglist (call, POINTER_TYPE, INTEGER_TYPE,
INTEGER_TYPE, VOID_TYPE); INTEGER_TYPE, VOID_TYPE);
case BUILT_IN_BZERO: case BUILT_IN_BZERO:
*size_arg = 1;
return validate_gimple_arglist (call, POINTER_TYPE, INTEGER_TYPE, return validate_gimple_arglist (call, POINTER_TYPE, INTEGER_TYPE,
VOID_TYPE); VOID_TYPE);
default: default:
...@@ -1285,11 +1291,17 @@ gimple_stringop_fixed_value (gimple vcall_stmt, tree icall_size, int prob, ...@@ -1285,11 +1291,17 @@ gimple_stringop_fixed_value (gimple vcall_stmt, tree icall_size, int prob,
basic_block cond_bb, icall_bb, vcall_bb, join_bb; basic_block cond_bb, icall_bb, vcall_bb, join_bb;
edge e_ci, e_cv, e_iv, e_ij, e_vj; edge e_ci, e_cv, e_iv, e_ij, e_vj;
gimple_stmt_iterator gsi; gimple_stmt_iterator gsi;
tree fndecl;
int size_arg;
fndecl = gimple_call_fndecl (vcall_stmt);
if (!interesting_stringop_to_profile_p (fndecl, vcall_stmt, &size_arg))
gcc_unreachable();
cond_bb = gimple_bb (vcall_stmt); cond_bb = gimple_bb (vcall_stmt);
gsi = gsi_for_stmt (vcall_stmt); gsi = gsi_for_stmt (vcall_stmt);
vcall_size = gimple_call_arg (vcall_stmt, 2); vcall_size = gimple_call_arg (vcall_stmt, size_arg);
optype = TREE_TYPE (vcall_size); optype = TREE_TYPE (vcall_size);
tmpv = create_tmp_var (optype, "PROF"); tmpv = create_tmp_var (optype, "PROF");
...@@ -1304,7 +1316,7 @@ gimple_stringop_fixed_value (gimple vcall_stmt, tree icall_size, int prob, ...@@ -1304,7 +1316,7 @@ gimple_stringop_fixed_value (gimple vcall_stmt, tree icall_size, int prob,
gsi_insert_before (&gsi, cond_stmt, GSI_SAME_STMT); gsi_insert_before (&gsi, cond_stmt, GSI_SAME_STMT);
icall_stmt = gimple_copy (vcall_stmt); icall_stmt = gimple_copy (vcall_stmt);
gimple_call_set_arg (icall_stmt, 2, icall_size); gimple_call_set_arg (icall_stmt, size_arg, icall_size);
gsi_insert_before (&gsi, icall_stmt, GSI_SAME_STMT); gsi_insert_before (&gsi, icall_stmt, GSI_SAME_STMT);
/* Fix CFG. */ /* Fix CFG. */
...@@ -1359,6 +1371,7 @@ gimple_stringops_transform (gimple_stmt_iterator *gsi) ...@@ -1359,6 +1371,7 @@ gimple_stringops_transform (gimple_stmt_iterator *gsi)
unsigned int dest_align, src_align; unsigned int dest_align, src_align;
gcov_type prob; gcov_type prob;
tree tree_val; tree tree_val;
int size_arg;
if (gimple_code (stmt) != GIMPLE_CALL) if (gimple_code (stmt) != GIMPLE_CALL)
return false; return false;
...@@ -1366,13 +1379,10 @@ gimple_stringops_transform (gimple_stmt_iterator *gsi) ...@@ -1366,13 +1379,10 @@ gimple_stringops_transform (gimple_stmt_iterator *gsi)
if (!fndecl) if (!fndecl)
return false; return false;
fcode = DECL_FUNCTION_CODE (fndecl); fcode = DECL_FUNCTION_CODE (fndecl);
if (!interesting_stringop_to_profile_p (fndecl, stmt)) if (!interesting_stringop_to_profile_p (fndecl, stmt, &size_arg))
return false; return false;
if (fcode == BUILT_IN_BZERO) blck_size = gimple_call_arg (stmt, size_arg);
blck_size = gimple_call_arg (stmt, 1);
else
blck_size = gimple_call_arg (stmt, 2);
if (TREE_CODE (blck_size) == INTEGER_CST) if (TREE_CODE (blck_size) == INTEGER_CST)
return false; return false;
...@@ -1583,6 +1593,7 @@ gimple_stringops_values_to_profile (gimple stmt, histogram_values *values) ...@@ -1583,6 +1593,7 @@ gimple_stringops_values_to_profile (gimple stmt, histogram_values *values)
tree blck_size; tree blck_size;
tree dest; tree dest;
enum built_in_function fcode; enum built_in_function fcode;
int size_arg;
if (gimple_code (stmt) != GIMPLE_CALL) if (gimple_code (stmt) != GIMPLE_CALL)
return; return;
...@@ -1591,14 +1602,11 @@ gimple_stringops_values_to_profile (gimple stmt, histogram_values *values) ...@@ -1591,14 +1602,11 @@ gimple_stringops_values_to_profile (gimple stmt, histogram_values *values)
return; return;
fcode = DECL_FUNCTION_CODE (fndecl); fcode = DECL_FUNCTION_CODE (fndecl);
if (!interesting_stringop_to_profile_p (fndecl, stmt)) if (!interesting_stringop_to_profile_p (fndecl, stmt, &size_arg))
return; return;
dest = gimple_call_arg (stmt, 0); dest = gimple_call_arg (stmt, 0);
if (fcode == BUILT_IN_BZERO) blck_size = gimple_call_arg (stmt, size_arg);
blck_size = gimple_call_arg (stmt, 1);
else
blck_size = gimple_call_arg (stmt, 2);
if (TREE_CODE (blck_size) != INTEGER_CST) if (TREE_CODE (blck_size) != INTEGER_CST)
{ {
......
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