diff mbox series

Remove quite obvious dead assignments.

Message ID 0a87fce7-2307-ddb3-7223-6f7c844b2a6f@suse.cz
State New
Headers show
Series Remove quite obvious dead assignments. | expand

Commit Message

Martin Liška June 26, 2019, 10:57 a.m. UTC
Hi.

I've spent some with clang-static-analyzer and I analyzed the warnings reported.
As always wit analyzers, majority of the issues are false positives, however it caught
couple of real issues:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90973
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90978
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90976
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90975
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90970

That said, I'm sending a patch that rapidly shrinks number of Dead assignments.
I've chosen to remove only these that are quite trivial and that do not span
among multiple if-else branches.

I hope the patch will be readable and approved.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests. I'm
also testing that on ppc64 big endian machine.

Ready to be installed?
Thanks,
Martin


gcc/ChangeLog:

2019-06-26  Martin Liska  <mliska@suse.cz>

	* asan.c (asan_emit_allocas_unpoison): Remove obviously
	dead assignments.
	* bt-load.c (move_btr_def): Likewise.
	* builtins.c (expand_builtin_apply_args_1): Likewise.
	(expand_builtin_apply): Likewise.
	* cfgexpand.c (expand_asm_stmt): Likewise.
	(construct_init_block): Likewise.
	* cfghooks.c (verify_flow_info): Likewise.
	* cfgloopmanip.c (remove_path): Likewise.
	* cfgrtl.c (rtl_verify_bb_layout): Likewise.
	* cgraph.c (cgraph_node::set_pure_flag): Likewise.
	* combine.c (simplify_if_then_else): Likewise.
	* config/i386/i386-expand.c (ix86_expand_rounddf_32): Likewise.
	* config/i386/i386.c (ix86_setup_incoming_vararg_bounds): Likewise.
	(choose_basereg): Likewise.
	(ix86_expand_prologue): Likewise.
	(ix86_preferred_output_reload_class): Likewise.
	* cselib.c (cselib_record_sets): Likewise.
	* df-scan.c (df_scan_alloc): Likewise.
	* dojump.c (do_jump_by_parts_greater_rtx): Likewise.
	* early-remat.c (early_remat::record_equiv_candidates): Likewise.
	* emit-rtl.c (try_split): Likewise.
	* graphite-scop-detection.c (assign_parameter_index_in_region): Likewise.
	* ipa-cp.c (cgraph_edge_brings_all_agg_vals_for_node): Likewise.
	* ira-color.c (setup_profitable_hard_regs): Likewise.
	* ira.c (rtx_moveable_p): Likewise.
	* lra-eliminations.c (eliminate_regs_in_insn): Likewise.
	* read-rtl.c (read_subst_mapping): Likewise.
	* regrename.c (scan_rtx): Likewise.
	* reorg.c (fill_slots_from_thread): Likewise.
	* tree-inline.c (tree_function_versioning): Likewise.
	* tree-ssa-reassoc.c (optimize_ops_list): Likewise.
	* tree-ssa-sink.c (statement_sink_location): Likewise.
	* tree-ssa-threadedge.c (thread_across_edge): Likewise.
	* tree-vect-loop.c (vect_get_loop_niters): Likewise.
	(vect_create_epilog_for_reduction): Likewise.
	* tree-vect-stmts.c (vectorizable_call): Likewise.
	* tree.c (build_nonstandard_integer_type): Likewise.

gcc/cp/ChangeLog:

2019-06-26  Martin Liska  <mliska@suse.cz>

	* class.c (adjust_clone_args): Remove obviously
	dead assignments.
	(dump_class_hierarchy_r): Likewise.
	* decl.c (check_initializer): Likewise.
	* parser.c (cp_parser_lambda_expression): Likewise.
	* pt.c (unify_bound_ttp_args): Likewise.
	(convert_template_argument): Likewise.
	* rtti.c (build_headof): Likewise.
	* typeck.c (convert_for_initialization): Likewise.

libgcc/ChangeLog:

2019-06-26  Martin Liska  <mliska@suse.cz>

	* libgcov-driver-system.c (gcov_exit_open_gcda_file): Remove obviously
	dead assignments.
	* libgcov-util.c: Likewise.
---
 gcc/asan.c                     |  4 ++--
 gcc/bt-load.c                  |  1 -
 gcc/builtins.c                 |  8 ++------
 gcc/cfgexpand.c                |  8 ++++----
 gcc/cfghooks.c                 |  2 --
 gcc/cfgloopmanip.c             |  1 -
 gcc/cfgrtl.c                   |  1 -
 gcc/cgraph.c                   |  2 --
 gcc/combine.c                  |  1 -
 gcc/config/i386/i386-expand.c  |  2 --
 gcc/config/i386/i386.c         | 13 ++-----------
 gcc/cp/class.c                 |  4 ----
 gcc/cp/decl.c                  |  2 +-
 gcc/cp/parser.c                |  2 +-
 gcc/cp/pt.c                    |  4 +---
 gcc/cp/rtti.c                  |  4 ++--
 gcc/cp/typeck.c                |  2 --
 gcc/cselib.c                   |  3 +--
 gcc/df-scan.c                  |  2 --
 gcc/dojump.c                   |  2 --
 gcc/early-remat.c              |  1 -
 gcc/emit-rtl.c                 |  2 +-
 gcc/graphite-scop-detection.c  |  2 --
 gcc/ipa-cp.c                   |  3 ---
 gcc/ira-color.c                |  1 -
 gcc/ira.c                      |  3 +--
 gcc/lra-eliminations.c         |  1 -
 gcc/read-rtl.c                 |  4 ++--
 gcc/regrename.c                |  3 +--
 gcc/reorg.c                    |  3 +--
 gcc/tree-inline.c              |  4 ++--
 gcc/tree-ssa-reassoc.c         |  3 ---
 gcc/tree-ssa-sink.c            |  1 -
 gcc/tree-ssa-threadedge.c      |  1 -
 gcc/tree-vect-loop.c           |  8 ++------
 gcc/tree-vect-stmts.c          |  6 ++----
 gcc/tree.c                     |  2 --
 libgcc/libgcov-driver-system.c |  4 +---
 libgcc/libgcov-util.c          |  3 +--
 39 files changed, 30 insertions(+), 93 deletions(-)

Comments

Jakub Jelinek June 26, 2019, 11:39 a.m. UTC | #1
On Wed, Jun 26, 2019 at 12:57:15PM +0200, Martin Liška wrote:
> --- a/gcc/asan.c
> +++ b/gcc/asan.c
> @@ -1713,8 +1713,8 @@ asan_emit_allocas_unpoison (rtx top, rtx bot, rtx_insn *before)
>    rtx ret = init_one_libfunc ("__asan_allocas_unpoison");
>    top = convert_memory_address (ptr_mode, top);
>    bot = convert_memory_address (ptr_mode, bot);
> -  ret = emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode,
> -				 top, ptr_mode, bot, ptr_mode);
> +  emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode,
> +			   top, ptr_mode, bot, ptr_mode);

If you don't need the return value, you should use emit_library_call,
not emit_library_call_value.

> --- a/gcc/cfgexpand.c
> +++ b/gcc/cfgexpand.c
> @@ -3044,7 +3044,7 @@ expand_asm_stmt (gasm *stmt)
>  	      }
>  	}
>      }
> -  unsigned nclobbers = clobber_rvec.length();
> +  unsigned nclobbers;

Can you instead move the nclobbers declaration to the spot where it
is initialized (right now the second time), and add space before (
there too?

> --- a/gcc/config/i386/i386-expand.c
> +++ b/gcc/config/i386/i386-expand.c
> @@ -16051,8 +16051,6 @@ ix86_expand_rounddf_32 (rtx operand0, rtx operand1)
>    mhalf = expand_simple_binop (mode, MINUS, half, one, NULL_RTX,
>  			       0, OPTAB_DIRECT);
>  
> -  /* Compensate.  */
> -  tmp = gen_reg_rtx (mode);
>    /* xa2 = xa2 - (dxa > 0.5 ? 1 : 0) */
>    tmp = ix86_expand_sse_compare_mask (UNGT, dxa, half, false);
>    emit_insn (gen_rtx_SET (tmp, gen_rtx_AND (mode, one, tmp)));

Is this really desirable?
Just quick look suggests perhaps it wants to use one temporary
for the gen_reg_rtx (mode) and use that on the lhs of SET, and another one
as the last operand to AND holding ix86_expand_sse_compare_mask?
Though, such problem is in most of the ix86_expand_sse_compare_mask callers.
While ix86_expand_sse_compare_mask returns a result of gen_reg_rtx too,
I think it is better not to reuse pseudos for different values.
I'd say take out this change and deal with it with i386 maintainers
separately.

> --- a/gcc/tree-vect-stmts.c
> +++ b/gcc/tree-vect-stmts.c
> @@ -3483,8 +3483,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
>  			= gimple_build_call_internal_vec (ifn, vargs);
>  		      gimple_call_set_lhs (call, half_res);
>  		      gimple_call_set_nothrow (call, true);
> -		      new_stmt_info
> -			= vect_finish_stmt_generation (stmt_info, call, gsi);
> +		      vect_finish_stmt_generation (stmt_info, call, gsi);
>  		      if ((i & 1) == 0)
>  			{
>  			  prev_res = half_res;
> @@ -3583,8 +3582,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
>  	      gcall *call = gimple_build_call_internal_vec (ifn, vargs);
>  	      gimple_call_set_lhs (call, half_res);
>  	      gimple_call_set_nothrow (call, true);
> -	      new_stmt_info
> -		= vect_finish_stmt_generation (stmt_info, call, gsi);
> +	      vect_finish_stmt_generation (stmt_info, call, gsi);
>  	      if ((j & 1) == 0)
>  		{
>  		  prev_res = half_res;

This looks wrong.
There should have been
SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt_info);
in between for slp_node, or the usual code like:
          if (cond_for_first)
            STMT_VINFO_VEC_STMT (stmt_info) = *vec_stmt = new_stmt_info;
          else
            STMT_VINFO_RELATED_STMT (prev_stmt_info) = new_stmt_info;
	  prev_stmt_info = new_stmt_info;
otherwise.  In any case, I think this should be dealt with separately.

	Jakub
Martin Jambor June 26, 2019, 11:52 a.m. UTC | #2
Hi,

On Wed, Jun 26 2019, Martin Liška wrote:
> Hi.
>
> I've spent some with clang-static-analyzer and I analyzed the warnings reported.
> As always wit analyzers, majority of the issues are false positives, however it caught
> couple of real issues:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90973
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90978
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90976
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90975
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90970
>
> That said, I'm sending a patch that rapidly shrinks number of Dead assignments.
> I've chosen to remove only these that are quite trivial and that do not span
> among multiple if-else branches.
>
> I hope the patch will be readable and approved.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests. I'm
> also testing that on ppc64 big endian machine.
>
> Ready to be installed?
> Thanks,
> Martin
>
>
> gcc/ChangeLog:
>
> 2019-06-26  Martin Liska  <mliska@suse.cz>
>
> 	* ipa-cp.c (cgraph_edge_brings_all_agg_vals_for_node): Likewise.

The ipa-cp.c hunk is obvious, I'd say.

Thanks,

Martin


> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
> index 69c00a9c5a5..b6e781f7450 100644
> --- a/gcc/ipa-cp.c
> +++ b/gcc/ipa-cp.c
> @@ -4445,7 +4445,6 @@ static bool
>  cgraph_edge_brings_all_agg_vals_for_node (struct cgraph_edge *cs,
>  					  struct cgraph_node *node)
>  {
> -  struct ipa_node_params *orig_caller_info = IPA_NODE_REF (cs->caller);
>    struct ipa_node_params *orig_node_info;
>    struct ipa_agg_replacement_value *aggval;
>    int i, ec, count;
> @@ -4462,8 +4461,6 @@ cgraph_edge_brings_all_agg_vals_for_node (struct cgraph_edge *cs,
>  	return false;
>  
>    orig_node_info = IPA_NODE_REF (IPA_NODE_REF (node)->ipcp_orig_node);
> -  if (orig_caller_info->ipcp_orig_node)
> -    orig_caller_info = IPA_NODE_REF (orig_caller_info->ipcp_orig_node);
>  
>    for (i = 0; i < count; i++)
>      {
Jeff Law June 26, 2019, 8:24 p.m. UTC | #3
On 6/26/19 4:57 AM, Martin Liška wrote:
> Hi.
> 
> I've spent some with clang-static-analyzer and I analyzed the warnings reported.
> As always wit analyzers, majority of the issues are false positives, however it caught
> couple of real issues:
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90973
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90978
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90976
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90975
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90970
> 
> That said, I'm sending a patch that rapidly shrinks number of Dead assignments.
> I've chosen to remove only these that are quite trivial and that do not span
> among multiple if-else branches.
> 
> I hope the patch will be readable and approved.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests. I'm
> also testing that on ppc64 big endian machine.
> 
> Ready to be installed?
> Thanks,
> Martin
> 
> 
> gcc/ChangeLog:
> 
> 2019-06-26  Martin Liska  <mliska@suse.cz>
> 
> 	* asan.c (asan_emit_allocas_unpoison): Remove obviously
> 	dead assignments.
> 	* bt-load.c (move_btr_def): Likewise.
> 	* builtins.c (expand_builtin_apply_args_1): Likewise.
> 	(expand_builtin_apply): Likewise.
> 	* cfgexpand.c (expand_asm_stmt): Likewise.
> 	(construct_init_block): Likewise.
> 	* cfghooks.c (verify_flow_info): Likewise.
> 	* cfgloopmanip.c (remove_path): Likewise.
> 	* cfgrtl.c (rtl_verify_bb_layout): Likewise.
> 	* cgraph.c (cgraph_node::set_pure_flag): Likewise.
> 	* combine.c (simplify_if_then_else): Likewise.
> 	* config/i386/i386-expand.c (ix86_expand_rounddf_32): Likewise.
> 	* config/i386/i386.c (ix86_setup_incoming_vararg_bounds): Likewise.
> 	(choose_basereg): Likewise.
> 	(ix86_expand_prologue): Likewise.
> 	(ix86_preferred_output_reload_class): Likewise.
> 	* cselib.c (cselib_record_sets): Likewise.
> 	* df-scan.c (df_scan_alloc): Likewise.
> 	* dojump.c (do_jump_by_parts_greater_rtx): Likewise.
> 	* early-remat.c (early_remat::record_equiv_candidates): Likewise.
> 	* emit-rtl.c (try_split): Likewise.
> 	* graphite-scop-detection.c (assign_parameter_index_in_region): Likewise.
> 	* ipa-cp.c (cgraph_edge_brings_all_agg_vals_for_node): Likewise.
> 	* ira-color.c (setup_profitable_hard_regs): Likewise.
> 	* ira.c (rtx_moveable_p): Likewise.
> 	* lra-eliminations.c (eliminate_regs_in_insn): Likewise.
> 	* read-rtl.c (read_subst_mapping): Likewise.
> 	* regrename.c (scan_rtx): Likewise.
> 	* reorg.c (fill_slots_from_thread): Likewise.
> 	* tree-inline.c (tree_function_versioning): Likewise.
> 	* tree-ssa-reassoc.c (optimize_ops_list): Likewise.
> 	* tree-ssa-sink.c (statement_sink_location): Likewise.
> 	* tree-ssa-threadedge.c (thread_across_edge): Likewise.
> 	* tree-vect-loop.c (vect_get_loop_niters): Likewise.
> 	(vect_create_epilog_for_reduction): Likewise.
> 	* tree-vect-stmts.c (vectorizable_call): Likewise.
> 	* tree.c (build_nonstandard_integer_type): Likewise.
> 
> gcc/cp/ChangeLog:
> 
> 2019-06-26  Martin Liska  <mliska@suse.cz>
> 
> 	* class.c (adjust_clone_args): Remove obviously
> 	dead assignments.
> 	(dump_class_hierarchy_r): Likewise.
> 	* decl.c (check_initializer): Likewise.
> 	* parser.c (cp_parser_lambda_expression): Likewise.
> 	* pt.c (unify_bound_ttp_args): Likewise.
> 	(convert_template_argument): Likewise.
> 	* rtti.c (build_headof): Likewise.
> 	* typeck.c (convert_for_initialization): Likewise.
> 
> libgcc/ChangeLog:
> 
> 2019-06-26  Martin Liska  <mliska@suse.cz>
> 
> 	* libgcov-driver-system.c (gcov_exit_open_gcda_file): Remove obviously
> 	dead assignments.
> 	* libgcov-util.c: Likewise.
I think you've already received a bit of feedback here, particularly WRT
emit_library_call vs emit_library_call_value.  I think this is fine for
the trunk once you've addressed the comments that have already been made.

jeff
Martin Liška June 27, 2019, 9:32 a.m. UTC | #4
On 6/26/19 1:39 PM, Jakub Jelinek wrote:
> On Wed, Jun 26, 2019 at 12:57:15PM +0200, Martin Liška wrote:
>> --- a/gcc/asan.c
>> +++ b/gcc/asan.c
>> @@ -1713,8 +1713,8 @@ asan_emit_allocas_unpoison (rtx top, rtx bot, rtx_insn *before)
>>    rtx ret = init_one_libfunc ("__asan_allocas_unpoison");
>>    top = convert_memory_address (ptr_mode, top);
>>    bot = convert_memory_address (ptr_mode, bot);
>> -  ret = emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode,
>> -				 top, ptr_mode, bot, ptr_mode);
>> +  emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode,
>> +			   top, ptr_mode, bot, ptr_mode);
> 
> If you don't need the return value, you should use emit_library_call,
> not emit_library_call_value.

Done.

> 
>> --- a/gcc/cfgexpand.c
>> +++ b/gcc/cfgexpand.c
>> @@ -3044,7 +3044,7 @@ expand_asm_stmt (gasm *stmt)
>>  	      }
>>  	}
>>      }
>> -  unsigned nclobbers = clobber_rvec.length();
>> +  unsigned nclobbers;
> 
> Can you instead move the nclobbers declaration to the spot where it
> is initialized (right now the second time), and add space before (
> there too?

Sure.

> 
>> --- a/gcc/config/i386/i386-expand.c
>> +++ b/gcc/config/i386/i386-expand.c
>> @@ -16051,8 +16051,6 @@ ix86_expand_rounddf_32 (rtx operand0, rtx operand1)
>>    mhalf = expand_simple_binop (mode, MINUS, half, one, NULL_RTX,
>>  			       0, OPTAB_DIRECT);
>>  
>> -  /* Compensate.  */
>> -  tmp = gen_reg_rtx (mode);
>>    /* xa2 = xa2 - (dxa > 0.5 ? 1 : 0) */
>>    tmp = ix86_expand_sse_compare_mask (UNGT, dxa, half, false);
>>    emit_insn (gen_rtx_SET (tmp, gen_rtx_AND (mode, one, tmp)));
> 
> Is this really desirable?
> Just quick look suggests perhaps it wants to use one temporary
> for the gen_reg_rtx (mode) and use that on the lhs of SET, and another one
> as the last operand to AND holding ix86_expand_sse_compare_mask?
> Though, such problem is in most of the ix86_expand_sse_compare_mask callers.
> While ix86_expand_sse_compare_mask returns a result of gen_reg_rtx too,
> I think it is better not to reuse pseudos for different values.
> I'd say take out this change and deal with it with i386 maintainers
> separately.

Good point, I've just created:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91016

> 
>> --- a/gcc/tree-vect-stmts.c
>> +++ b/gcc/tree-vect-stmts.c
>> @@ -3483,8 +3483,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
>>  			= gimple_build_call_internal_vec (ifn, vargs);
>>  		      gimple_call_set_lhs (call, half_res);
>>  		      gimple_call_set_nothrow (call, true);
>> -		      new_stmt_info
>> -			= vect_finish_stmt_generation (stmt_info, call, gsi);
>> +		      vect_finish_stmt_generation (stmt_info, call, gsi);
>>  		      if ((i & 1) == 0)
>>  			{
>>  			  prev_res = half_res;
>> @@ -3583,8 +3582,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
>>  	      gcall *call = gimple_build_call_internal_vec (ifn, vargs);
>>  	      gimple_call_set_lhs (call, half_res);
>>  	      gimple_call_set_nothrow (call, true);
>> -	      new_stmt_info
>> -		= vect_finish_stmt_generation (stmt_info, call, gsi);
>> +	      vect_finish_stmt_generation (stmt_info, call, gsi);
>>  	      if ((j & 1) == 0)
>>  		{
>>  		  prev_res = half_res;
> 
> This looks wrong.
> There should have been
> SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt_info);
> in between for slp_node, or the usual code like:
>           if (cond_for_first)
>             STMT_VINFO_VEC_STMT (stmt_info) = *vec_stmt = new_stmt_info;
>           else
>             STMT_VINFO_RELATED_STMT (prev_stmt_info) = new_stmt_info;
> 	  prev_stmt_info = new_stmt_info;
> otherwise.  In any case, I think this should be dealt with separately.

Likewise here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91017

I'm going to install updated patch once regression tests finish for it.
I excluded changes for the PR mentioned.

Martin

> 
> 	Jakub
>
Richard Sandiford June 27, 2019, 10:06 a.m. UTC | #5
Martin Liška <mliska@suse.cz> writes:
> On 6/26/19 1:39 PM, Jakub Jelinek wrote:
>> On Wed, Jun 26, 2019 at 12:57:15PM +0200, Martin Liška wrote:
>>> --- a/gcc/tree-vect-stmts.c
>>> +++ b/gcc/tree-vect-stmts.c
>>> @@ -3483,8 +3483,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
>>>  			= gimple_build_call_internal_vec (ifn, vargs);
>>>  		      gimple_call_set_lhs (call, half_res);
>>>  		      gimple_call_set_nothrow (call, true);
>>> -		      new_stmt_info
>>> -			= vect_finish_stmt_generation (stmt_info, call, gsi);
>>> +		      vect_finish_stmt_generation (stmt_info, call, gsi);
>>>  		      if ((i & 1) == 0)
>>>  			{
>>>  			  prev_res = half_res;
>>> @@ -3583,8 +3582,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
>>>  	      gcall *call = gimple_build_call_internal_vec (ifn, vargs);
>>>  	      gimple_call_set_lhs (call, half_res);
>>>  	      gimple_call_set_nothrow (call, true);
>>> -	      new_stmt_info
>>> -		= vect_finish_stmt_generation (stmt_info, call, gsi);
>>> +	      vect_finish_stmt_generation (stmt_info, call, gsi);
>>>  	      if ((j & 1) == 0)
>>>  		{
>>>  		  prev_res = half_res;
>> 
>> This looks wrong.
>> There should have been
>> SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt_info);
>> in between for slp_node, or the usual code like:
>>           if (cond_for_first)
>>             STMT_VINFO_VEC_STMT (stmt_info) = *vec_stmt = new_stmt_info;
>>           else
>>             STMT_VINFO_RELATED_STMT (prev_stmt_info) = new_stmt_info;
>> 	  prev_stmt_info = new_stmt_info;
>> otherwise.  In any case, I think this should be dealt with separately.
>
> Likewise here:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91017

I think this part of the patch is OK.  SLP_TREE_VEC_STMTS and
STMT_VINFO_VEC_STMT should only receive the final stmt for each vector
result, whereas these stmts are producing intermediate results.

The assignments were introduced as part of a mechanical patch to avoid
using vinfo_for_stmt to get stmt_infos that we'd just created.  I'd
missed that in these cases we didn't actually use vinfo_for_stmt.

Off-hand, I'm not sure whether we actually need to create the
stmt_info here as things stand, or whether we're really just using
vect_finish_stmt_generation to insert the stmt in the right way.
I did have some WIP patches that would need the stmt_info to be
created though.

Thanks,
Richard
diff mbox series

Patch

diff --git a/gcc/asan.c b/gcc/asan.c
index 3b800b26b69..916aa9008fc 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1713,8 +1713,8 @@  asan_emit_allocas_unpoison (rtx top, rtx bot, rtx_insn *before)
   rtx ret = init_one_libfunc ("__asan_allocas_unpoison");
   top = convert_memory_address (ptr_mode, top);
   bot = convert_memory_address (ptr_mode, bot);
-  ret = emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode,
-				 top, ptr_mode, bot, ptr_mode);
+  emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode,
+			   top, ptr_mode, bot, ptr_mode);
 
   do_pending_stack_adjust ();
   rtx_insn *insns = get_insns ();
diff --git a/gcc/bt-load.c b/gcc/bt-load.c
index a7d9d53954e..f68879ca49a 100644
--- a/gcc/bt-load.c
+++ b/gcc/bt-load.c
@@ -1169,7 +1169,6 @@  move_btr_def (basic_block new_def_bb, int btr, btr_def *def, bitmap live_range,
 
   if (def->other_btr_uses_before_def)
     {
-      insp = BB_END (b);
       for (insp = BB_END (b); ! INSN_P (insp); insp = PREV_INSN (insp))
 	gcc_assert (insp != BB_HEAD (b));
 
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 4ecfd49d03c..c53afe8b033 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -1638,11 +1638,8 @@  expand_builtin_apply_args_1 (void)
   /* Save the structure value address unless this is passed as an
      "invisible" first argument.  */
   if (struct_incoming_value)
-    {
-      emit_move_insn (adjust_address (registers, Pmode, size),
-		      copy_to_reg (struct_incoming_value));
-      size += GET_MODE_SIZE (Pmode);
-    }
+    emit_move_insn (adjust_address (registers, Pmode, size),
+		    copy_to_reg (struct_incoming_value));
 
   /* Return the address of the block.  */
   return copy_addr_to_reg (XEXP (registers, 0));
@@ -1791,7 +1788,6 @@  expand_builtin_apply (rtx function, rtx arguments, rtx argsize)
       emit_move_insn (struct_value, value);
       if (REG_P (struct_value))
 	use_reg (&call_fusage, struct_value);
-      size += GET_MODE_SIZE (Pmode);
     }
 
   /* All arguments and registers used for the call are set up by now!  */
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index cc8eed6181a..0b490810445 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3044,7 +3044,7 @@  expand_asm_stmt (gasm *stmt)
 	      }
 	}
     }
-  unsigned nclobbers = clobber_rvec.length();
+  unsigned nclobbers;
 
   /* First pass over inputs and outputs checks validity and sets
      mark_addressable if needed.  */
@@ -5997,11 +5997,11 @@  construct_init_block (void)
     {
       first_block = e->dest;
       redirect_edge_succ (e, init_block);
-      e = make_single_succ_edge (init_block, first_block, flags);
+      make_single_succ_edge (init_block, first_block, flags);
     }
   else
-    e = make_single_succ_edge (init_block, EXIT_BLOCK_PTR_FOR_FN (cfun),
-			       EDGE_FALLTHRU);
+    make_single_succ_edge (init_block, EXIT_BLOCK_PTR_FOR_FN (cfun),
+			   EDGE_FALLTHRU);
 
   update_bb_for_insn (init_block);
   return init_block;
diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
index a25441b2640..76183ecf6ae 100644
--- a/gcc/cfghooks.c
+++ b/gcc/cfghooks.c
@@ -259,8 +259,6 @@  verify_flow_info (void)
 	err = 1;
       }
 
-  last_bb_seen = ENTRY_BLOCK_PTR_FOR_FN (cfun);
-
   /* Clean up.  */
   free (last_visited);
   free (edge_checksum);
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index 50250ec4d7c..b5f6a47fb80 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -364,7 +364,6 @@  remove_path (edge e, bool *irred_invalidated,
 
   for (i = 0; i < nrem; i++)
     {
-      bb = rem_bbs[i];
       FOR_EACH_EDGE (ae, ei, rem_bbs[i]->succs)
 	if (ae->dest != EXIT_BLOCK_PTR_FOR_FN (cfun)
 	    && !bitmap_bit_p (seen, ae->dest->index))
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index a1ca5992c41..a6e4c1bf572 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -2968,7 +2968,6 @@  rtl_verify_bb_layout (void)
   basic_block last_bb_seen = ENTRY_BLOCK_PTR_FOR_FN (cfun), curr_bb = NULL;
 
   num_bb_notes = 0;
-  last_bb_seen = ENTRY_BLOCK_PTR_FOR_FN (cfun);
 
   for (x = rtx_first; x; x = NEXT_INSN (x))
     {
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 28019aba434..d161db96f14 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -2714,8 +2714,6 @@  bool
 cgraph_node::set_pure_flag (bool pure, bool looping)
 {
   struct set_pure_flag_info info = {pure, looping, false};
-  if (!pure)
-    looping = false;
   call_for_symbol_thunks_and_aliases (set_pure_flag_1, &info, !pure, true);
   return info.changed;
 }
diff --git a/gcc/combine.c b/gcc/combine.c
index ce7aeecb5c2..1be922df614 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -6592,7 +6592,6 @@  simplify_if_then_else (rtx x)
 	  || reg_mentioned_p (true_rtx, false_rtx)
 	  || rtx_equal_p (false_rtx, XEXP (cond, 0))))
     {
-      true_code = reversed_comparison_code (cond, NULL);
       SUBST (XEXP (x, 0), reversed_comparison (cond, GET_MODE (cond)));
       SUBST (XEXP (x, 1), false_rtx);
       SUBST (XEXP (x, 2), true_rtx);
diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index d50b811d863..749789b569b 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -16051,8 +16051,6 @@  ix86_expand_rounddf_32 (rtx operand0, rtx operand1)
   mhalf = expand_simple_binop (mode, MINUS, half, one, NULL_RTX,
 			       0, OPTAB_DIRECT);
 
-  /* Compensate.  */
-  tmp = gen_reg_rtx (mode);
   /* xa2 = xa2 - (dxa > 0.5 ? 1 : 0) */
   tmp = ix86_expand_sse_compare_mask (UNGT, dxa, half, false);
   emit_insn (gen_rtx_SET (tmp, gen_rtx_AND (mode, one, tmp)));
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 1ca1712183d..cd72dc603bc 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -4136,7 +4136,6 @@  ix86_setup_incoming_vararg_bounds (cumulative_args_t cum_v,
   CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
   CUMULATIVE_ARGS next_cum;
   tree fntype;
-  int max;
 
   gcc_assert (!no_rtl);
 
@@ -4152,10 +4151,6 @@  ix86_setup_incoming_vararg_bounds (cumulative_args_t cum_v,
   if (stdarg_p (fntype))
     ix86_function_arg_advance (pack_cumulative_args (&next_cum), mode, type,
 			       true);
-
-  max = cum->regno + cfun->va_list_gpr_size / UNITS_PER_WORD;
-  if (max > X86_64_REGPARM_MAX)
-    max = X86_64_REGPARM_MAX;
 }
 
 
@@ -6291,7 +6286,6 @@  choose_basereg (HOST_WIDE_INT cfa_offset, rtx &base_reg,
 	    {
 	      base_reg = hard_frame_pointer_rtx;
 	      base_offset = toffset;
-	      len = tlen;
 	    }
 	}
     }
@@ -8003,8 +7997,7 @@  ix86_expand_prologue (void)
 				   GEN_INT (-allocate), -1, false);
 
       /* Align the stack.  */
-      insn = emit_insn (gen_and2_insn (stack_pointer_rtx,
-				       GEN_INT (-align_bytes)));
+      emit_insn (gen_and2_insn (stack_pointer_rtx, GEN_INT (-align_bytes)));
       m->fs.sp_offset = ROUND_UP (m->fs.sp_offset, align_bytes);
       m->fs.sp_realigned_offset = m->fs.sp_offset
 					      - frame.stack_realign_allocate;
@@ -18176,12 +18169,10 @@  ix86_preferred_reload_class (rtx x, reg_class_t regclass)
 static reg_class_t
 ix86_preferred_output_reload_class (rtx x, reg_class_t regclass)
 {
-  machine_mode mode = GET_MODE (x);
-
   /* Restrict the output reload class to the register bank that we are doing
      math on.  If we would like not to return a subset of CLASS, reject this
      alternative: if reload cannot do this, it will still use its choice.  */
-  mode = GET_MODE (x);
+  machine_mode mode = GET_MODE (x);
   if (SSE_FLOAT_MODE_P (mode) && TARGET_SSE_MATH)
     return MAYBE_SSE_CLASS_P (regclass) ? ALL_SSE_REGS : NO_REGS;
 
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index a679e651bbe..18e7db08c8d 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -4718,8 +4718,6 @@  adjust_clone_args (tree decl)
       tree orig_decl_parms = TYPE_ARG_TYPES (TREE_TYPE (decl));
       tree decl_parms, clone_parms;
 
-      clone_parms = orig_clone_parms;
-
       /* Skip the 'this' parameter.  */
       orig_clone_parms = TREE_CHAIN (orig_clone_parms);
       orig_decl_parms = TREE_CHAIN (orig_decl_parms);
@@ -8549,7 +8547,6 @@  dump_class_hierarchy_r (FILE *stream,
   tree base_binfo;
   int i;
 
-  indented = maybe_indent_hierarchy (stream, indent, 0);
   fprintf (stream, "%s (0x" HOST_WIDE_INT_PRINT_HEX ") ",
 	   type_as_string (BINFO_TYPE (binfo), TFF_PLAIN_IDENTIFIER),
 	   (HOST_WIDE_INT) (uintptr_t) binfo);
@@ -8570,7 +8567,6 @@  dump_class_hierarchy_r (FILE *stream,
     fprintf (stream, " virtual");
   fprintf (stream, "\n");
 
-  indented = 0;
   if (BINFO_PRIMARY_P (binfo))
     {
       indented = maybe_indent_hierarchy (stream, indent + 3, indented);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 96cd4843a1c..bb9d19a8172 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6401,7 +6401,7 @@  build_aggr_init_full_exprs (tree decl, tree init, int flags)
 static tree
 check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
 {
-  tree type = TREE_TYPE (decl);
+  tree type;
   tree init_code = NULL;
   tree core_type;
 
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4d46cb3eac7..0a3edb3229d 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -10478,7 +10478,7 @@  cp_parser_lambda_expression (cp_parser* parser)
     if (ok)
       maybe_add_lambda_conv_op (type);
 
-    type = finish_struct (type, /*attributes=*/NULL_TREE);
+    finish_struct (type, /*attributes=*/NULL_TREE);
 
     parser->num_template_parameter_lists = saved_num_template_parameter_lists;
     parser->in_statement = in_statement;
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 00e436429ce..cc306fcaa89 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -7457,8 +7457,7 @@  unify_bound_ttp_args (tree tparms, tree targs, tree parm, tree& arg,
     {
       /* In keeping with P0522R0, adjust P's template arguments
 	 to apply to A's template; then flatten it again.  */
-      tree nparmvec = parmvec;
-      nparmvec = coerce_ttp_args_for_tta (arg, parmvec, tf_none);
+      tree nparmvec = coerce_ttp_args_for_tta (arg, parmvec, tf_none);
       nparmvec = expand_template_argument_pack (nparmvec);
 
       if (unify (tparms, targs, nparmvec, argvec,
@@ -7885,7 +7884,6 @@  convert_template_argument (tree parm,
 	 invalid, but static members are OK.  In any
 	 case, grab the underlying fields/functions
 	 and issue an error later if required.  */
-      orig_arg = TREE_VALUE (arg);
       TREE_TYPE (arg) = unknown_type_node;
     }
 
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index ef78564e88f..eb1b062a49b 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -209,8 +209,8 @@  build_headof (tree exp)
   offset = build_vtbl_ref (cp_build_fold_indirect_ref (exp),
                            index);
 
-  type = cp_build_qualified_type (ptr_type_node,
-				  cp_type_quals (TREE_TYPE (exp)));
+  cp_build_qualified_type (ptr_type_node,
+			   cp_type_quals (TREE_TYPE (exp)));
   return fold_build_pointer_plus (exp, offset);
 }
 
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 550064cf9fd..dd76ebe3dbf 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -9189,8 +9189,6 @@  convert_for_initialization (tree exp, tree type, tree rhs, int flags,
   if (exp == error_mark_node)
     return error_mark_node;
 
-  rhstype = non_reference (rhstype);
-
   type = complete_type (type);
 
   if (DIRECT_INIT_EXPR_P (type, rhs))
diff --git a/gcc/cselib.c b/gcc/cselib.c
index a1cbdec9718..7b0545e779c 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -2518,13 +2518,12 @@  cselib_record_sets (rtx_insn *insn)
   int n_sets = 0;
   int i;
   struct cselib_set sets[MAX_SETS];
-  rtx body = PATTERN (insn);
   rtx cond = 0;
   int n_sets_before_autoinc;
   int n_strict_low_parts = 0;
   struct cselib_record_autoinc_data data;
 
-  body = PATTERN (insn);
+  rtx body = PATTERN (insn);
   if (GET_CODE (body) == COND_EXEC)
     {
       cond = COND_EXEC_TEST (body);
diff --git a/gcc/df-scan.c b/gcc/df-scan.c
index 2eea149e458..81e221ee38f 100644
--- a/gcc/df-scan.c
+++ b/gcc/df-scan.c
@@ -229,7 +229,6 @@  void
 df_scan_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
 {
   struct df_scan_problem_data *problem_data;
-  unsigned int insn_num = get_max_uid () + 1;
   basic_block bb;
 
   /* Given the number of pools, this is really faster than tearing
@@ -257,7 +256,6 @@  df_scan_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
   bitmap_obstack_initialize (&problem_data->reg_bitmaps);
   bitmap_obstack_initialize (&problem_data->insn_bitmaps);
 
-  insn_num += insn_num / 4;
   df_grow_reg_info ();
 
   df_grow_insn_info ();
diff --git a/gcc/dojump.c b/gcc/dojump.c
index 8626689463e..bac37a357a9 100644
--- a/gcc/dojump.c
+++ b/gcc/dojump.c
@@ -668,8 +668,6 @@  do_jump_by_parts_greater_rtx (scalar_int_mode mode, int unsignedp, rtx op0,
       code = LE;
       if_true_label = if_false_label;
       if_false_label = drop_through_label;
-      drop_through_if_true = false;
-      drop_through_if_false = true;
       prob = prob.invert ();
     }
 
diff --git a/gcc/early-remat.c b/gcc/early-remat.c
index 122891c1edb..0396f16babf 100644
--- a/gcc/early-remat.c
+++ b/gcc/early-remat.c
@@ -1123,7 +1123,6 @@  early_remat::record_equiv_candidates (unsigned int cand1_index,
       ec->representative = cand1_index;
       cand1->equiv_class = ec;
     }
-  cand1 = &m_candidates[ec->representative];
   cand2->equiv_class = ec;
   bitmap_set_bit (ec->members, cand2_index);
   if (cand2_index > ec->representative)
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 58286f797c4..e265fa68bce 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -4017,7 +4017,7 @@  try_split (rtx pat, rtx_insn *trial, int last)
   before = PREV_INSN (trial);
   after = NEXT_INSN (trial);
 
-  tem = emit_insn_after_setloc (seq, trial, INSN_LOCATION (trial));
+  emit_insn_after_setloc (seq, trial, INSN_LOCATION (trial));
 
   delete_insn (trial);
 
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 4534d43721f..489d0b93b42 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1105,14 +1105,12 @@  assign_parameter_index_in_region (tree name, sese_info_p region)
   gcc_assert (TREE_CODE (name) == SSA_NAME
 	      && INTEGRAL_TYPE_P (TREE_TYPE (name))
 	      && ! defined_in_sese_p (name, region->region));
-
   int i;
   tree p;
   FOR_EACH_VEC_ELT (region->params, i, p)
     if (p == name)
       return;
 
-  i = region->params.length ();
   region->params.safe_push (name);
 }
 
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 69c00a9c5a5..b6e781f7450 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -4445,7 +4445,6 @@  static bool
 cgraph_edge_brings_all_agg_vals_for_node (struct cgraph_edge *cs,
 					  struct cgraph_node *node)
 {
-  struct ipa_node_params *orig_caller_info = IPA_NODE_REF (cs->caller);
   struct ipa_node_params *orig_node_info;
   struct ipa_agg_replacement_value *aggval;
   int i, ec, count;
@@ -4462,8 +4461,6 @@  cgraph_edge_brings_all_agg_vals_for_node (struct cgraph_edge *cs,
 	return false;
 
   orig_node_info = IPA_NODE_REF (IPA_NODE_REF (node)->ipcp_orig_node);
-  if (orig_caller_info->ipcp_orig_node)
-    orig_caller_info = IPA_NODE_REF (orig_caller_info->ipcp_orig_node);
 
   for (i = 0; i < count; i++)
     {
diff --git a/gcc/ira-color.c b/gcc/ira-color.c
index aa91b56c81f..8a90ae1b4e6 100644
--- a/gcc/ira-color.c
+++ b/gcc/ira-color.c
@@ -1108,7 +1108,6 @@  setup_profitable_hard_regs (void)
 	  || empty_profitable_hard_regs (a))
 	continue;
       data = ALLOCNO_COLOR_DATA (a);
-      mode = ALLOCNO_MODE (a);
       if ((costs = ALLOCNO_UPDATED_HARD_REG_COSTS (a)) != NULL
 	  || (costs = ALLOCNO_HARD_REG_COSTS (a)) != NULL)
 	{
diff --git a/gcc/ira.c b/gcc/ira.c
index 725636d8dc5..d4ea68f17c0 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -4414,10 +4414,9 @@  rtx_moveable_p (rtx *loc, enum op_type type)
 {
   const char *fmt;
   rtx x = *loc;
-  enum rtx_code code = GET_CODE (x);
   int i, j;
 
-  code = GET_CODE (x);
+  enum rtx_code code = GET_CODE (x);
   switch (code)
     {
     case CONST:
diff --git a/gcc/lra-eliminations.c b/gcc/lra-eliminations.c
index fa0ebcd8ed9..f344e127cfe 100644
--- a/gcc/lra-eliminations.c
+++ b/gcc/lra-eliminations.c
@@ -1054,7 +1054,6 @@  eliminate_regs_in_insn (rtx_insn *insn, bool replace_p, bool first_p,
      single_set without having put new body into the insn and the
      re-recognition won't hurt in this rare case.  */
   id = lra_update_insn_recog_data (insn);
-  static_id = id->insn_static_data;
 }
 
 /* Spill pseudos which are assigned to hard registers in SET.  Add
diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c
index f37708f6967..6b1b811cbfe 100644
--- a/gcc/read-rtl.c
+++ b/gcc/read-rtl.c
@@ -1295,7 +1295,7 @@  read_subst_mapping (htab_t subst_iters_table, htab_t subst_attrs_table,
       m = add_mapping (&substs, subst_iters_table, attr_operands[1]);
       end_ptr = &m->values;
       end_ptr = add_map_value (end_ptr, 1, "");
-      end_ptr = add_map_value (end_ptr, 2, "");
+      add_map_value (end_ptr, 2, "");
 
       add_define_attr_for_define_subst (attr_operands[1], queue);
     }
@@ -1303,7 +1303,7 @@  read_subst_mapping (htab_t subst_iters_table, htab_t subst_attrs_table,
   m = add_mapping (&substs, subst_attrs_table, attr_operands[0]);
   end_ptr = &m->values;
   end_ptr = add_map_value (end_ptr, 1, attr_operands[2]);
-  end_ptr = add_map_value (end_ptr, 2, attr_operands[3]);
+  add_map_value (end_ptr, 2, attr_operands[3]);
 }
 
 /* Check newly-created code iterator ITERATOR to see whether every code has the
diff --git a/gcc/regrename.c b/gcc/regrename.c
index 637b3cbe6d7..5259d565e58 100644
--- a/gcc/regrename.c
+++ b/gcc/regrename.c
@@ -1426,10 +1426,9 @@  scan_rtx (rtx_insn *insn, rtx *loc, enum reg_class cl, enum scan_actions action,
 {
   const char *fmt;
   rtx x = *loc;
-  enum rtx_code code = GET_CODE (x);
   int i, j;
 
-  code = GET_CODE (x);
+  enum rtx_code code = GET_CODE (x);
   switch (code)
     {
     case CONST:
diff --git a/gcc/reorg.c b/gcc/reorg.c
index 81349382b81..bdfcf8851cd 100644
--- a/gcc/reorg.c
+++ b/gcc/reorg.c
@@ -2708,14 +2708,13 @@  fill_slots_from_thread (rtx_jump_insn *insn, rtx condition,
       && GET_CODE (PATTERN (new_thread)) != ASM_INPUT
       && asm_noperands (PATTERN (new_thread)) < 0)
     {
-      rtx pat = PATTERN (new_thread);
       rtx dest;
       rtx src;
 
       /* We know "new_thread" is an insn due to NONJUMP_INSN_P (new_thread)
 	 above.  */
       trial = as_a <rtx_insn *> (new_thread);
-      pat = PATTERN (trial);
+      rtx pat = PATTERN (trial);
 
       if (!NONJUMP_INSN_P (trial)
 	  || GET_CODE (pat) != SET
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 2de5e22f10f..d61fb28e48b 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -6231,11 +6231,11 @@  tree_function_versioning (tree old_decl, tree new_decl,
 	     in the debug info that var (whole DECL_ORIGIN is the parm
 	     PARM_DECL) is optimized away, but could be looked up at the
 	     call site as value of D#X there.  */
-	  tree var = vars, vexpr;
+	  tree vexpr;
 	  gimple_stmt_iterator cgsi
 	    = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
 	  gimple *def_temp;
-	  var = vars;
+	  tree var = vars;
 	  i = vec_safe_length (*debug_args);
 	  do
 	    {
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 6794fbde29e..9c1a9a651fe 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -2039,9 +2039,6 @@  optimize_ops_list (enum tree_code opcode,
       i++;
     }
 
-  length = ops->length ();
-  oelast = ops->last ();
-
   if (iterate)
     optimize_ops_list (opcode, ops);
 }
diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c
index 67dc127e3fc..3bfad0f90ed 100644
--- a/gcc/tree-ssa-sink.c
+++ b/gcc/tree-ssa-sink.c
@@ -433,7 +433,6 @@  statement_sink_location (gimple *stmt, basic_block frombb,
 
       if (gimple_code (use) != GIMPLE_PHI)
 	{
-	  sinkbb = gimple_bb (use);
 	  sinkbb = select_best_block (frombb, gimple_bb (use), stmt);
 
 	  if (sinkbb == frombb)
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index 785227df690..39ea22f0554 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -1361,7 +1361,6 @@  thread_across_edge (gcond *dummy_cond,
 
         x = new jump_thread_edge (taken_edge, EDGE_COPY_SRC_JOINER_BLOCK);
 	path->safe_push (x);
-	found = false;
 	found = thread_around_empty_blocks (taken_edge,
 					    dummy_cond,
 					    avail_exprs_stack,
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index b37bf6f427d..95c2d8203ac 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -730,9 +730,7 @@  vect_get_loop_niters (struct loop *loop, tree *assumptions,
   if (!exit)
     return cond;
 
-  niter = chrec_dont_know;
   may_be_zero = NULL_TREE;
-  niter_assumptions = boolean_true_node;
   if (!number_of_iterations_exit_assumptions (loop, exit, &niter_desc, NULL)
       || chrec_contains_undetermined (niter_desc.niter))
     return cond;
@@ -5113,7 +5111,6 @@  vect_create_epilog_for_reduction (vec<tree> vect_defs,
 	  if (off != 0)
 	    {
 	      tree new_idx_val = idx_val;
-	      tree new_val = val;
 	      if (off != v_size - el_size)
 		{
 		  new_idx_val = make_ssa_name (idx_eltype);
@@ -5122,7 +5119,7 @@  vect_create_epilog_for_reduction (vec<tree> vect_defs,
 						     old_idx_val);
 		  gsi_insert_before (&exit_gsi, epilog_stmt, GSI_SAME_STMT);
 		}
-	      new_val = make_ssa_name (data_eltype);
+	      tree new_val = make_ssa_name (data_eltype);
 	      epilog_stmt = gimple_build_assign (new_val,
 						 COND_EXPR,
 						 build2 (GT_EXPR,
@@ -5303,14 +5300,13 @@  vect_create_epilog_for_reduction (vec<tree> vect_defs,
 	 in a vector mode of smaller size and first reduce upper/lower
 	 halves against each other.  */
       enum machine_mode mode1 = mode;
-      tree vectype1 = vectype;
       unsigned sz = tree_to_uhwi (TYPE_SIZE_UNIT (vectype));
       unsigned sz1 = sz;
       if (!slp_reduc
 	  && (mode1 = targetm.vectorize.split_reduction (mode)) != mode)
 	sz1 = GET_MODE_SIZE (mode1).to_constant ();
 
-      vectype1 = get_vectype_for_scalar_type_and_size (scalar_type, sz1);
+      tree vectype1 = get_vectype_for_scalar_type_and_size (scalar_type, sz1);
       reduce_with_shift = have_whole_vector_shift (mode1);
       if (!VECTOR_MODE_P (mode1))
 	reduce_with_shift = false;
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 47da2953dc7..415ac0c8679 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -3483,8 +3483,7 @@  vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
 			= gimple_build_call_internal_vec (ifn, vargs);
 		      gimple_call_set_lhs (call, half_res);
 		      gimple_call_set_nothrow (call, true);
-		      new_stmt_info
-			= vect_finish_stmt_generation (stmt_info, call, gsi);
+		      vect_finish_stmt_generation (stmt_info, call, gsi);
 		      if ((i & 1) == 0)
 			{
 			  prev_res = half_res;
@@ -3583,8 +3582,7 @@  vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
 	      gcall *call = gimple_build_call_internal_vec (ifn, vargs);
 	      gimple_call_set_lhs (call, half_res);
 	      gimple_call_set_nothrow (call, true);
-	      new_stmt_info
-		= vect_finish_stmt_generation (stmt_info, call, gsi);
+	      vect_finish_stmt_generation (stmt_info, call, gsi);
 	      if ((j & 1) == 0)
 		{
 		  prev_res = half_res;
diff --git a/gcc/tree.c b/gcc/tree.c
index c97facd7ce5..2032a936973 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -8212,8 +8212,6 @@  build_nonstandard_integer_type (unsigned HOST_WIDE_INT precision,
   else
     fixup_signed_type (itype);
 
-  ret = itype;
-
   inchash::hash hstate;
   inchash::add_expr (TYPE_MAX_VALUE (itype), hstate);
   ret = type_hash_canon (hstate.end (), itype);
diff --git a/libgcc/libgcov-driver-system.c b/libgcc/libgcov-driver-system.c
index 39dc62749d5..7d48a1f87d8 100644
--- a/libgcc/libgcov-driver-system.c
+++ b/libgcc/libgcov-driver-system.c
@@ -263,10 +263,8 @@  static int
 gcov_exit_open_gcda_file (struct gcov_info *gi_ptr,
 			  struct gcov_filename *gf)
 {
-  const char *fname = gi_ptr->filename;
   int append_slash = 0;
-
-  fname = gi_ptr->filename;
+  const char *fname = gi_ptr->filename;
 
   /* Build relocated filename, stripping off leading
      directories from the initial filename if requested. */
diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c
index c794132c172..6a94b80810b 100644
--- a/libgcc/libgcov-util.c
+++ b/libgcc/libgcov-util.c
@@ -461,10 +461,9 @@  gcov_read_profile_dir (const char* dir_name, int recompute_summary ATTRIBUTE_UNU
 #ifdef HAVE_FTW_H
   ftw (".", ftw_read_file, 50);
 #endif
-  ret = chdir (pwd);
+  chdir (pwd);
   free (pwd);
 
-
   return gcov_info_head;;
 }