Remove some "set but not used" variables

View: New views
3 Messages — Rating Filter:   Alert me  

Remove some "set but not used" variables

by d binderman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Hello there,

Please find attached a small patch which removes some trivially
redundant variables from the source code of version 4.5 snapshot 20091105.

Here is a possible ChangeLog entry

2009-11-07  David Binderman <dcb314@...>

        * builtins.c (apply_args_size, expand_builtin_mathfn, expand_powi,
        expand_builtin_expect, maybe_emit_sprintf_chk_warning):
        Remove some set but not used variables.
        * calls.c (flags_from_decl_or_type): Same.
        * genautomata.c (check_regexp_units_distribution): Same.

I've built and tested the patch and it seemed ok to me.

Regards

David Binderman
     
_________________________________________________________________
New Windows 7: Find the right PC for you. Learn more.
http://www.microsoft.com/uk/windows/buy/

--- gcc/builtins.c.sav 2009-11-06 19:32:09.000000000 +0000
+++ gcc/builtins.c 2009-11-07 10:03:53.000000000 +0000
@@ -1263,7 +1263,7 @@
    gives the offset of that register into the block returned by
    __builtin_apply_args.  0 indicates that the register is not
    used for calling a function.  */
-static int apply_args_reg_offset[FIRST_PSEUDO_REGISTER];
+/* static int apply_args_reg_offset[FIRST_PSEUDO_REGISTER]; not used */
 
 /* Return the size required for the block returned by __builtin_apply_args,
    and initialize apply_args_mode.  */
@@ -1297,14 +1297,12 @@
     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
     if (size % align != 0)
       size = CEIL (size, align) * align;
-    apply_args_reg_offset[regno] = size;
     size += GET_MODE_SIZE (mode);
     apply_args_mode[regno] = mode;
   }
  else
   {
     apply_args_mode[regno] = VOIDmode;
-    apply_args_reg_offset[regno] = 0;
   }
     }
   return size;
@@ -1924,7 +1922,7 @@
 expand_builtin_mathfn (tree exp, rtx target, rtx subtarget)
 {
   optab builtin_optab;
-  rtx op0, insns, before_call;
+  rtx op0, insns;
   tree fndecl = get_callee_fndecl (exp);
   enum machine_mode mode;
   bool errno_set = false;
@@ -2031,8 +2029,6 @@
       end_sequence ();
     }
 
-  before_call = get_last_insn ();
-
   return expand_call (exp, target, target == const0_rtx);
 }
 
@@ -2903,15 +2899,12 @@
 static rtx
 expand_powi (rtx x, enum machine_mode mode, HOST_WIDE_INT n)
 {
-  unsigned HOST_WIDE_INT val;
   rtx cache[POWI_TABLE_SIZE];
   rtx result;
 
   if (n == 0)
     return CONST1_RTX (mode);
 
-  val = (n < 0) ? -n : n;
-
   memset (cache, 0, sizeof (cache));
   cache[1] = x;
 
@@ -4893,12 +4886,11 @@
 static rtx
 expand_builtin_expect (tree exp, rtx target)
 {
-  tree arg, c;
+  tree arg;
 
   if (call_expr_nargs (exp) < 2)
     return const0_rtx;
   arg = CALL_EXPR_ARG (exp, 0);
-  c = CALL_EXPR_ARG (exp, 1);
 
   target = expand_expr (arg, target, VOIDmode, EXPAND_NORMAL);
   /* When guessing was done, the hints should be already stripped away.  */
@@ -12140,7 +12132,7 @@
 static void
 maybe_emit_sprintf_chk_warning (tree exp, enum built_in_function fcode)
 {
-  tree dest, size, len, fmt, flag;
+  tree size, len, fmt;
   const char *fmt_str;
   int nargs = call_expr_nargs (exp);
 
@@ -12148,8 +12140,6 @@
   
   if (nargs < 4)
     return;
-  dest = CALL_EXPR_ARG (exp, 0);
-  flag = CALL_EXPR_ARG (exp, 1);
   size = CALL_EXPR_ARG (exp, 2);
   fmt = CALL_EXPR_ARG (exp, 3);
 
--- gcc/calls.c.sav 2009-11-07 10:05:29.000000000 +0000
+++ gcc/calls.c 2009-11-07 10:06:16.000000000 +0000
@@ -589,12 +589,9 @@
 flags_from_decl_or_type (const_tree exp)
 {
   int flags = 0;
-  const_tree type = exp;
 
   if (DECL_P (exp))
     {
-      type = TREE_TYPE (exp);
-
       /* The function exp may have the `malloc' attribute.  */
       if (DECL_IS_MALLOC (exp))
  flags |= ECF_MALLOC;
--- gcc/genautomata.c.sav 2009-11-06 19:31:26.000000000 +0000
+++ gcc/genautomata.c 2009-11-06 19:31:49.000000000 +0000
@@ -5045,7 +5045,7 @@
 check_regexp_units_distribution (const char *insn_reserv_name,
  regexp_t regexp)
 {
-  int i, j, k, cycle, cycle2, start, n_alts, alt, alt2;
+  int i, j, k, cycle, start, n_alts, alt, alt2;
   bool annotation_reservation_message_reported_p;
   regexp_t seq, allof, unit;
   struct unit_usage *unit_usage_ptr;
@@ -5164,7 +5164,6 @@
    j < (int) VEC_length (unit_usage_t, cycle_alt_unit_usages);
    j++)
  {
-  cycle2 = j / n_alts;
   alt2 = j % n_alts;
   if (! unit_present_on_list_p
         (VEC_index (unit_usage_t, cycle_alt_unit_usages,


Re: Remove some "set but not used" variables

by Ian Lance Taylor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

d binderman <dcb314@...> writes:

> 2009-11-07  David Binderman <dcb314@...>
>
>         * builtins.c (apply_args_size, expand_builtin_mathfn, expand_powi,
>         expand_builtin_expect, maybe_emit_sprintf_chk_warning):
>         Remove some set but not used variables.
>         * calls.c (flags_from_decl_or_type): Same.
>         * genautomata.c (check_regexp_units_distribution): Same.

The ChangeLog entry needs to mention the removal of
apply_args_reg_offset.

> --- gcc/builtins.c.sav 2009-11-06 19:32:09.000000000 +0000
> +++ gcc/builtins.c 2009-11-07 10:03:53.000000000 +0000
> @@ -1263,7 +1263,7 @@
>     gives the offset of that register into the block returned by
>     __builtin_apply_args.  0 indicates that the register is not
>     used for calling a function.  */
> -static int apply_args_reg_offset[FIRST_PSEUDO_REGISTER];
> +/* static int apply_args_reg_offset[FIRST_PSEUDO_REGISTER]; not used */

Please remove this variable and its comment, don't just comment it
out.

This is OK with that change.

Thanks.

Ian

Re: Remove some "set but not used" variables

by Paolo Carlini-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ian Lance Taylor wrote:

>> 2009-11-07  David Binderman <dcb314@...>
>>
>>         * builtins.c (apply_args_size, expand_builtin_mathfn, expand_powi,
>>         expand_builtin_expect, maybe_emit_sprintf_chk_warning):
>>         Remove some set but not used variables.
>>         * calls.c (flags_from_decl_or_type): Same.
>>         * genautomata.c (check_regexp_units_distribution): Same.
>>    
> The ChangeLog entry needs to mention the removal of
>
> apply_args_reg_offset.
>> --- gcc/builtins.c.sav 2009-11-06 19:32:09.000000000 +0000
>> +++ gcc/builtins.c 2009-11-07 10:03:53.000000000 +0000
>> @@ -1263,7 +1263,7 @@
>>     gives the offset of that register into the block returned by
>>     __builtin_apply_args.  0 indicates that the register is not
>>     used for calling a function.  */
>> -static int apply_args_reg_offset[FIRST_PSEUDO_REGISTER];
>> +/* static int apply_args_reg_offset[FIRST_PSEUDO_REGISTER]; not used */
>>    
>
> Please remove this variable and its comment, don't just comment it
> out.
>  
Thanks Ian, I took care of these nits on top of the already committed
changes (as ok-ed by Richard), sorry for not having noticed those myself.

Paolo.