builtins.c (c_getstr, [...]): Export.

2014-08-08  Richard Biener  <rguenther@suse.de>

	* builtins.c (c_getstr, readonly_data_expr, init_target_chars,
	target_percent, target_percent_s): Export.
	(var_decl_component_p, fold_builtin_memory_op, fold_builtin_memset,
	fold_builtin_bzero, fold_builtin_strcpy, fold_builtin_strncpy,
	fold_builtin_strcat, fold_builtin_fputs, fold_builtin_memory_chk,
	fold_builtin_stxcpy_chk, fold_builtin_stxncpy_chk,
	fold_builtin_sprintf_chk_1, fold_builtin_snprintf_chk_1):
	Move to gimple-fold.c.
	(fold_builtin_2): Remove handling of bzero, fputs, fputs_unlocked,
	strcat and strcpy.
	(fold_builtin_3): Remove handling of memset, bcopy, memcpy,
	mempcpy, memmove, strncpy, strcpy_chk and stpcpy_chk.
	(fold_builtin_4): Remove handling of memcpy_chk, mempcpy_chk,
	memmove_chk, memset_chk, strncpy_chk and stpncpy_chk.
	(rewrite_call_expr_array): Remove.
	(fold_builtin_sprintf_chk): Likewise.
	(fold_builtin_snprintf_chk): Likewise.
	(fold_builtin_varargs): Remove handling of sprintf_chk,
	vsprintf_chk, snprintf_chk and vsnprintf_chk.
	(gimple_fold_builtin_sprintf_chk): Remove.
	(gimple_fold_builtin_snprintf_chk): Likewise.
	(gimple_fold_builtin_varargs): Likewise.
	(fold_call_stmt): Do not call gimple_fold_builtin_varargs.
	* predict.c (optimize_bb_for_size_p): Handle NULL bb.
	* gimple.c (gimple_seq_add_seq_without_update): New function.
	* gimple.h (gimple_seq_add_seq_without_update): Declare.
	* gimple-fold.c: Include output.h.
	(gsi_replace_with_seq_vops): New function, split out from ...
	(gimplify_and_update_call_from_tree): ... here.
	(replace_call_with_value): New function.
	(replace_call_with_call_and_fold): Likewise.
	(var_decl_component_p): Moved from builtins.c.
	(gimple_fold_builtin_memory_op): Moved from builtins.c
	fold_builtin_memory_op and rewritten to GIMPLE.
	(gimple_fold_builtin_memset): Likewise.
	(gimple_fold_builtin_strcpy): Likewise.
	(gimple_fold_builtin_strncpy): Likewise.
	(gimple_fold_builtin_strcat): Likewise.
	(gimple_fold_builtin_fputs): Likewise.
	(gimple_fold_builtin_memory_chk): Likewise.
	(gimple_fold_builtin_stxcpy_chk): Likewise.
	(gimple_fold_builtin_stxncpy_chk): Likewise.
	(gimple_fold_builtin_snprintf_chk): Likewise.
	(gimple_fold_builtin_sprintf_chk): Likewise.
	(gimple_fold_builtin_strlen): New function.
	(gimple_fold_builtin_with_strlen): New function split out from
	gimple_fold_builtin.
	(gimple_fold_builtin): Change signature and handle
	bzero, memset, bcopy, memcpy, mempcpy and memmove folding
	here.  Call gimple_fold_builtin_with_strlen.
	(gimple_fold_call): Adjust.

	* gcc.dg/strlenopt-8.c: Remove XFAIL.
	* gcc.dg/tree-prof/stringop-2.c: Adjust.
	* gfortran.dg/array_memcpy_4.f90: Likewise.
	* gfortran.dg/trim_optimize_1.f90: Likewise.
	* gfortran.dg/trim_optimize_2.f90: Likewise.

From-SVN: r213753
This commit is contained in:
Richard Biener 2014-08-08 09:18:40 +00:00 committed by Richard Biener
parent 322d490e02
commit fef5a0d95e
13 changed files with 1559 additions and 1480 deletions

View File

@ -1,3 +1,57 @@
2014-08-08 Richard Biener <rguenther@suse.de>
* builtins.c (c_getstr, readonly_data_expr, init_target_chars,
target_percent, target_percent_s): Export.
(var_decl_component_p, fold_builtin_memory_op, fold_builtin_memset,
fold_builtin_bzero, fold_builtin_strcpy, fold_builtin_strncpy,
fold_builtin_strcat, fold_builtin_fputs, fold_builtin_memory_chk,
fold_builtin_stxcpy_chk, fold_builtin_stxncpy_chk,
fold_builtin_sprintf_chk_1, fold_builtin_snprintf_chk_1):
Move to gimple-fold.c.
(fold_builtin_2): Remove handling of bzero, fputs, fputs_unlocked,
strcat and strcpy.
(fold_builtin_3): Remove handling of memset, bcopy, memcpy,
mempcpy, memmove, strncpy, strcpy_chk and stpcpy_chk.
(fold_builtin_4): Remove handling of memcpy_chk, mempcpy_chk,
memmove_chk, memset_chk, strncpy_chk and stpncpy_chk.
(rewrite_call_expr_array): Remove.
(fold_builtin_sprintf_chk): Likewise.
(fold_builtin_snprintf_chk): Likewise.
(fold_builtin_varargs): Remove handling of sprintf_chk,
vsprintf_chk, snprintf_chk and vsnprintf_chk.
(gimple_fold_builtin_sprintf_chk): Remove.
(gimple_fold_builtin_snprintf_chk): Likewise.
(gimple_fold_builtin_varargs): Likewise.
(fold_call_stmt): Do not call gimple_fold_builtin_varargs.
* predict.c (optimize_bb_for_size_p): Handle NULL bb.
* gimple.c (gimple_seq_add_seq_without_update): New function.
* gimple.h (gimple_seq_add_seq_without_update): Declare.
* gimple-fold.c: Include output.h.
(gsi_replace_with_seq_vops): New function, split out from ...
(gimplify_and_update_call_from_tree): ... here.
(replace_call_with_value): New function.
(replace_call_with_call_and_fold): Likewise.
(var_decl_component_p): Moved from builtins.c.
(gimple_fold_builtin_memory_op): Moved from builtins.c
fold_builtin_memory_op and rewritten to GIMPLE.
(gimple_fold_builtin_memset): Likewise.
(gimple_fold_builtin_strcpy): Likewise.
(gimple_fold_builtin_strncpy): Likewise.
(gimple_fold_builtin_strcat): Likewise.
(gimple_fold_builtin_fputs): Likewise.
(gimple_fold_builtin_memory_chk): Likewise.
(gimple_fold_builtin_stxcpy_chk): Likewise.
(gimple_fold_builtin_stxncpy_chk): Likewise.
(gimple_fold_builtin_snprintf_chk): Likewise.
(gimple_fold_builtin_sprintf_chk): Likewise.
(gimple_fold_builtin_strlen): New function.
(gimple_fold_builtin_with_strlen): New function split out from
gimple_fold_builtin.
(gimple_fold_builtin): Change signature and handle
bzero, memset, bcopy, memcpy, mempcpy and memmove folding
here. Call gimple_fold_builtin_with_strlen.
(gimple_fold_call): Adjust.
2014-08-08 Kugan Vivekanandarajah <kuganv@linaro.org>
* calls.c (precompute_arguments): Check

File diff suppressed because it is too large Load Diff

View File

@ -71,29 +71,23 @@ extern void expand_builtin_trap (void);
extern rtx expand_builtin (tree, rtx, rtx, enum machine_mode, int);
extern enum built_in_function builtin_mathfn_code (const_tree);
extern tree fold_builtin_expect (location_t, tree, tree, tree);
extern tree fold_builtin_strcpy (location_t, tree, tree, tree, tree);
extern tree fold_builtin_strncpy (location_t, tree, tree, tree, tree, tree);
extern tree fold_fma (location_t, tree, tree, tree, tree);
extern bool avoid_folding_inline_builtin (tree);
extern tree fold_call_expr (location_t, tree, bool);
extern tree fold_builtin_call_array (location_t, tree, tree, int, tree *);
extern bool validate_gimple_arglist (const_gimple, ...);
extern rtx default_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
extern tree fold_builtin_strcat (location_t, tree, tree, tree);
extern tree fold_builtin_fputs (location_t, tree, tree, bool, bool, tree);
extern bool fold_builtin_next_arg (tree, bool);
extern tree fold_builtin_memory_chk (location_t, tree, tree, tree, tree, tree,
tree, bool, enum built_in_function);
extern tree fold_builtin_stxcpy_chk (location_t, tree, tree, tree, tree, tree,
bool, enum built_in_function);
extern tree fold_builtin_stxncpy_chk (location_t, tree, tree, tree, tree, tree,
bool, enum built_in_function);
extern tree gimple_fold_builtin_snprintf_chk (gimple, tree,
enum built_in_function);
extern tree do_mpc_arg2 (tree, tree, tree, int, int (*)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t));
extern tree fold_call_stmt (gimple, bool);
extern void set_builtin_user_assembler_name (tree decl, const char *asmspec);
extern bool is_simple_builtin (tree);
extern bool is_inexpensive_builtin (tree);
extern bool readonly_data_expr (tree exp);
extern const char *c_getstr (tree);
extern bool init_target_chars (void);
extern unsigned HOST_WIDE_INT target_percent;
extern char target_percent_s[3];
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1178,6 +1178,21 @@ gimple_seq_add_seq (gimple_seq *dst_p, gimple_seq src)
gsi_insert_seq_after (&si, src, GSI_NEW_STMT);
}
/* Append sequence SRC to the end of sequence *DST_P. If *DST_P is
NULL, a new sequence is allocated. This function is
similar to gimple_seq_add_seq, but does not scan the operands. */
void
gimple_seq_add_seq_without_update (gimple_seq *dst_p, gimple_seq src)
{
gimple_stmt_iterator si;
if (src == NULL)
return;
si = gsi_last (*dst_p);
gsi_insert_seq_after_without_update (&si, src, GSI_NEW_STMT);
}
/* Determine whether to assign a location to the statement GS. */
static bool

View File

@ -1226,6 +1226,7 @@ gimple gimple_build_predict (enum br_predictor, enum prediction);
extern void gimple_seq_add_stmt (gimple_seq *, gimple);
extern void gimple_seq_add_stmt_without_update (gimple_seq *, gimple);
void gimple_seq_add_seq (gimple_seq *, gimple_seq);
void gimple_seq_add_seq_without_update (gimple_seq *, gimple_seq);
extern void annotate_all_with_location_after (gimple_seq, gimple_stmt_iterator,
location_t);
extern void annotate_all_with_location (gimple_seq, location_t);

View File

@ -339,7 +339,8 @@ optimize_function_for_speed_p (struct function *fun)
bool
optimize_bb_for_size_p (const_basic_block bb)
{
return optimize_function_for_size_p (cfun) || !maybe_hot_bb_p (cfun, bb);
return (optimize_function_for_size_p (cfun)
|| (bb && !maybe_hot_bb_p (cfun, bb)));
}
/* Return TRUE when BB should be optimized for speed. */

View File

@ -1,3 +1,11 @@
2014-08-08 Richard Biener <rguenther@suse.de>
* gcc.dg/strlenopt-8.c: Remove XFAIL.
* gcc.dg/tree-prof/stringop-2.c: Adjust.
* gfortran.dg/array_memcpy_4.f90: Likewise.
* gfortran.dg/trim_optimize_1.f90: Likewise.
* gfortran.dg/trim_optimize_2.f90: Likewise.
2014-08-08 Kugan Vivekanandarajah <kuganv@linaro.org>
* gcc.dg/zero_sign_ext_test.c: New test.

View File

@ -43,8 +43,8 @@ main ()
return 0;
}
/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" { xfail *-*-* } } } */
/* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen" { xfail *-*-* } } } */
/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */
/* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen" } } */
/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */

View File

@ -19,6 +19,6 @@ main()
}
/* { dg-final-use { scan-ipa-dump "Single value 4 stringop" "profile"} } */
/* The versioned memset of size 4 should be optimized to an assignment. */
/* { dg-final-use { scan-tree-dump "a\\\[0\\\] = 168430090" "optimized"} } */
/* { dg-final-use { scan-tree-dump "MEM\\\[\\(void .\\)&a\\\] = 168430090" "optimized"} } */
/* { dg-final-use { cleanup-tree-dump "optimized" } } */
/* { dg-final-use { cleanup-ipa-dump "profile" } } */

View File

@ -9,5 +9,5 @@
d = s
end
! { dg-final { scan-tree-dump-times "MEM.*d\\\] = MEM" 1 "original" } }
! { dg-final { scan-tree-dump-times "memcpy" 1 "original" } }
! { dg-final { cleanup-tree-dump "original" } }

View File

@ -11,6 +11,6 @@ program main
if (c /= 'abc') call abort
end program main
! { dg-final { scan-tree-dump-times "memmove" 2 "original" } }
! { dg-final { scan-tree-dump-times "memmove" 3 "original" } }
! { dg-final { scan-tree-dump-times "string_trim" 0 "original" } }
! { dg-final { cleanup-tree-dump "original" } }

View File

@ -32,6 +32,6 @@ contains
end subroutine foo
end program main
! { dg-final { scan-tree-dump-times "memmove" 4 "original" } }
! { dg-final { scan-tree-dump-times "memmove" 6 "original" } }
! { dg-final { scan-tree-dump-times "string_trim" 0 "original" } }
! { dg-final { cleanup-tree-dump "original" } }