This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[patch] Beginner projects: combine.c, code clean-ups


Hi,

Please find attached my first attempt to patch combine.c. It contains some
typo fixes for comments and adds comments for long and/or nested 'ifdefs'.

It also deletes some unused code.
Firstly, the function 'sets_function_arg_p', which was introduced by this change

Sun Nov  9 09:24:21 1997  J"orn Rennecke <amylaar@cygnus.co.uk>

        * combine.c (sets_function_arg_p): New function.
        (combinable_i3pat): Check if combining with any but the first
        argument register setting insn for a function call.

the only call to it was deleted by this change

2000-12-01  Bernd Schmidt  <bernds@redhat.co.uk>

        * combine.c (cant_combine_insn_p): Only disallow insns involving
        hard regs if they are reg-reg moves.
        (try_combine, can_combine_p, combinable_i3pat): Delete old
        SMALL_REGISTER_CLASSES tests.


Secondly, two ifdef 0 blocks are deleted which have been present since

Mon Dec 16 15:28:44 1996  Jim Wilson  <wilson@cygnus.com>

        * combine.c (nonzero_bits): Ifdef out calls to num_sign_bit_copies.
        Add dummy define/undef for num_sign_bit_copies.

There are more of these old ifdef 0 blocks present, which I plan on
patching later. Is it helpfull or just a nuisance to include their change
history?

Bootstrapped and tested without regressions on Mainline for i686-pc-linux-gnu

jan



2001-05-15  Jan van Male  <jan.vanmale@fenk.wau.nl>

        * combine.c: fix typos in comments
        * combine.c: add comments to various ifdef constructs
        * combine.c (sets_function_arg_p): unused, deleted
        (nonzero_bits): delete if 0 blocks


Index: gcc/combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.198
diff -c -3 -p -r1.198 combine.c
*** combine.c   2001/05/11 16:15:49     1.198
--- combine.c   2001/05/15 15:30:18
*************** Boston, MA 02111-1307, USA.  */
*** 50,56 ****
     information (LOG_LINKS and REG_NOTES) for what we did.

     There are a few exceptions where the dataflow information created by
!    flow.c aren't completely updated:

     - reg_live_length is not updated
     - reg_n_refs is not adjusted in the rare case when a register is
--- 50,56 ----
     information (LOG_LINKS and REG_NOTES) for what we did.

     There are a few exceptions where the dataflow information created by
!    flow.c isn't completely updated:

     - reg_live_length is not updated
     - reg_n_refs is not adjusted in the rare case when a register is
*************** static void setup_incoming_promotions
*** 346,352 ****
  static void set_nonzero_bits_and_sign_copies  PARAMS ((rtx, rtx, void *));
  static int cant_combine_insn_p        PARAMS ((rtx));
  static int can_combine_p      PARAMS ((rtx, rtx, rtx, rtx, rtx *, rtx *));
- static int sets_function_arg_p        PARAMS ((rtx));
  static int combinable_i3pat   PARAMS ((rtx, rtx *, rtx, rtx, int, rtx *));
  static int contains_muldiv    PARAMS ((rtx));
  static rtx try_combine                PARAMS ((rtx, rtx, rtx, int *));
--- 346,351 ----
*************** combine_instructions (f, nregs)
*** 693,699 ****
                && (next = try_combine (insn, XEXP (links, 0),
                                        prev, &new_direct_jump_p)) != 0)
              goto retry;
! #endif

          /* Try combining an insn with two different insns whose results it
             uses.  */
--- 692,698 ----
                && (next = try_combine (insn, XEXP (links, 0),
                                        prev, &new_direct_jump_p)) != 0)
              goto retry;
! #endif /* HAVE_cc0 */

          /* Try combining an insn with two different insns whose results it
             uses.  */
*************** setup_incoming_promotions ()
*** 804,810 ****
                                      GET_MODE (reg),
                                      gen_rtx_CLOBBER (mode, const0_rtx)));
        }
! #endif
  }
  
  /* Called via note_stores.  If X is a pseudo that is narrower than
--- 803,809 ----
                                      GET_MODE (reg),
                                      gen_rtx_CLOBBER (mode, const0_rtx)));
        }
! #endif /* PROMOTE_FUNCTION_ARGS */
  }
  
  /* Called via note_stores.  If X is a pseudo that is narrower than
*************** set_nonzero_bits_and_sign_copies (x, set
*** 874,880 ****
            src = GEN_INT (INTVAL (src)
                           | ((HOST_WIDE_INT) (-1)
                              << GET_MODE_BITSIZE (GET_MODE (x))));
! #endif

          reg_nonzero_bits[REGNO (x)]
            |= nonzero_bits (src, nonzero_bits_mode);
--- 873,879 ----
            src = GEN_INT (INTVAL (src)
                           | ((HOST_WIDE_INT) (-1)
                              << GET_MODE_BITSIZE (GET_MODE (x))));
! #endif /* SHORT_IMMEDIATES_SIGN_EXTEND */

          reg_nonzero_bits[REGNO (x)]
            |= nonzero_bits (src, nonzero_bits_mode);
*************** can_combine_p (insn, i3, pred, succ, pde
*** 1190,1235 ****
    return 1;
  }
  
- /* Check if PAT is an insn - or a part of it - used to set up an
-    argument for a function in a hard register.  */
-
- static int
- sets_function_arg_p (pat)
-      rtx pat;
- {
-   int i;
-   rtx inner_dest;
-
-   switch (GET_CODE (pat))
-     {
-     case INSN:
-       return sets_function_arg_p (PATTERN (pat));
-
-     case PARALLEL:
-       for (i = XVECLEN (pat, 0); --i >= 0;)
-       if (sets_function_arg_p (XVECEXP (pat, 0, i)))
-         return 1;
-
-       break;
-
-     case SET:
-       inner_dest = SET_DEST (pat);
-       while (GET_CODE (inner_dest) == STRICT_LOW_PART
-            || GET_CODE (inner_dest) == SUBREG
-            || GET_CODE (inner_dest) == ZERO_EXTRACT)
-       inner_dest = XEXP (inner_dest, 0);
-
-       return (GET_CODE (inner_dest) == REG
-             && REGNO (inner_dest) < FIRST_PSEUDO_REGISTER
-             && FUNCTION_ARG_REGNO_P (REGNO (inner_dest)));
-
-     default:
-       break;
-     }
-
-   return 0;
- }
-
  /* LOC is the location within I3 that contains its pattern or the component
     of a PARALLEL of the pattern.  We validate that it is valid for combining.

--- 1189,1194 ----
*************** try_combine (i3, i2, i1, new_direct_jump
*** 1730,1736 ****
                 SET_DEST (PATTERN (i1)));
        }
      }
! #endif

    /* Verify that I2 and I1 are valid for combining.  */
    if (! can_combine_p (i2, i3, i1, NULL_RTX, &i2dest, &i2src)
--- 1689,1695 ----
                 SET_DEST (PATTERN (i1)));
        }
      }
! #endif /* not HAVE_cc0 */

    /* Verify that I2 and I1 are valid for combining.  */
    if (! can_combine_p (i2, i3, i1, NULL_RTX, &i2dest, &i2src)
*************** try_combine (i3, i2, i1, new_direct_jump
*** 1923,1932 ****
          else
            undobuf.other_insn = 0;
        }
! #endif
      }
    else
! #endif
      {
        n_occurrences = 0;              /* `subst' counts here */

--- 1882,1891 ----
          else
            undobuf.other_insn = 0;
        }
! #endif /* EXTRA_CC_MODES */
      }
    else
! #endif /* not HAVE_cc0 */
      {
        n_occurrences = 0;              /* `subst' counts here */

*************** subst (x, from, to, in_dest, unique_copy
*** 3495,3502 ****
     expression.

     OP0_MODE is the original mode of XEXP (x, 0); LAST is nonzero if this
!    will be the iteration even if an expression with a code different from
!    X is returned; IN_DEST is nonzero if we are inside a SET_DEST.  */

  static rtx
  combine_simplify_rtx (x, op0_mode, last, in_dest)
--- 3454,3461 ----
     expression.

     OP0_MODE is the original mode of XEXP (x, 0); LAST is nonzero if this
!    will be the last iteration even if an expression with a code different
!    from X is returned; IN_DEST is nonzero if we are inside a SET_DEST.  */

  static rtx
  combine_simplify_rtx (x, op0_mode, last, in_dest)
*************** simplify_set (x)
*** 5070,5076 ****
              dest = new_dest;
            }
        }
! #endif

        /* If the code changed, we have to build a new comparison in
         undobuf.other_insn.  */
--- 5029,5035 ----
              dest = new_dest;
            }
        }
! #endif /* not HAVE_cc0, and EXTRA_CC_MODES */

        /* If the code changed, we have to build a new comparison in
         undobuf.other_insn.  */
*************** simplify_set (x)
*** 5272,5278 ****
      return make_field_assignment (x);
  }
  
! /* Simplify, X, and AND, IOR, or XOR operation, and return the simplified
     result.  LAST is nonzero if this is the last retry.  */

  static rtx
--- 5231,5237 ----
      return make_field_assignment (x);
  }
  
! /* Simplify X, an AND, IOR, or XOR operation, and return the simplified
     result.  LAST is nonzero if this is the last retry.  */

  static rtx
*************** force_to_mode (x, mode, mask, reg, just_
*** 6921,6927 ****
                                                       + STACK_BIAS),
                                        mode, smask, reg, next_select);
              }
! #endif
            if ((nonzero_bits (XEXP (x, 0), mode) & ~smask) == 0
                && (INTVAL (XEXP (x, 1)) & ~smask) != 0)
              return force_to_mode (plus_constant (XEXP (x, 0),
--- 6880,6886 ----
                                                       + STACK_BIAS),
                                        mode, smask, reg, next_select);
              }
! #endif /* STACK_BIAS */
            if ((nonzero_bits (XEXP (x, 0), mode) & ~smask) == 0
                && (INTVAL (XEXP (x, 1)) & ~smask) != 0)
              return force_to_mode (plus_constant (XEXP (x, 0),
*************** apply_distributive_law (x)
*** 7848,7854 ****

    /* Set LHS and RHS to the inner operands (A and B in the example
       above) and set OTHER to the common operand (C in the example).
!      These is only one way to do this unless the inner operation is
       commutative.  */
    if (GET_RTX_CLASS (inner_code) == 'c'
        && rtx_equal_p (XEXP (lhs, 0), XEXP (rhs, 0)))
--- 7807,7813 ----

    /* Set LHS and RHS to the inner operands (A and B in the example
       above) and set OTHER to the common operand (C in the example).
!      There is only one way to do this unless the inner operation is
       commutative.  */
    if (GET_RTX_CLASS (inner_code) == 'c'
        && rtx_equal_p (XEXP (lhs, 0), XEXP (rhs, 0)))
*************** apply_distributive_law (x)
*** 7875,7881 ****
        other = simplify_gen_unary (NOT, GET_MODE (x), other, GET_MODE (x));
      }

!   /* We may be able to continuing distributing the result, so call
       ourselves recursively on the inner operation before forming the
       outer operation, which we return.  */
    return gen_binary (inner_code, GET_MODE (x),
--- 7834,7840 ----
        other = simplify_gen_unary (NOT, GET_MODE (x), other, GET_MODE (x));
      }

!   /* We may be able to continue distributing the result, so call
       ourselves recursively on the inner operation before forming the
       outer operation, which we return.  */
    return gen_binary (inner_code, GET_MODE (x),
*************** nonzero_bits (x, mode)
*** 8085,8091 ****
             far as the stack pointer is concerned.  */
          return nonzero &= ~(sp_alignment - 1);
        }
! #endif

        /* If X is a register whose nonzero bits value is current, use it.
         Otherwise, if X is a register whose value we can find, use that
--- 8044,8050 ----
             far as the stack pointer is concerned.  */
          return nonzero &= ~(sp_alignment - 1);
        }
! #endif /* STACK_BOUNDARY */

        /* If X is a register whose nonzero bits value is current, use it.
         Otherwise, if X is a register whose value we can find, use that
*************** nonzero_bits (x, mode)
*** 8125,8131 ****
            tem = GEN_INT (INTVAL (tem)
                           | ((HOST_WIDE_INT) (-1)
                              << GET_MODE_BITSIZE (GET_MODE (x))));
! #endif
          return nonzero_bits (tem, mode);
        }
        else if (nonzero_sign_valid && reg_nonzero_bits[REGNO (x)])
--- 8084,8090 ----
            tem = GEN_INT (INTVAL (tem)
                           | ((HOST_WIDE_INT) (-1)
                              << GET_MODE_BITSIZE (GET_MODE (x))));
! #endif /* SHORT_IMMEDIATES_SIGN_EXTEND */
          return nonzero_bits (tem, mode);
        }
        else if (nonzero_sign_valid && reg_nonzero_bits[REGNO (x)])
*************** nonzero_bits (x, mode)
*** 8171,8196 ****
        break;

      case NEG:
- #if 0
-       /* Disabled to avoid exponential mutual recursion between nonzero_bits
-        and num_sign_bit_copies.  */
-       if (num_sign_bit_copies (XEXP (x, 0), GET_MODE (x))
-         == GET_MODE_BITSIZE (GET_MODE (x)))
-       nonzero = 1;
- #endif
-
        if (GET_MODE_SIZE (GET_MODE (x)) < mode_width)
        nonzero |= (GET_MODE_MASK (mode) & ~GET_MODE_MASK (GET_MODE (x)));
        break;

      case ABS:
- #if 0
-       /* Disabled to avoid exponential mutual recursion between nonzero_bits
-        and num_sign_bit_copies.  */
-       if (num_sign_bit_copies (XEXP (x, 0), GET_MODE (x))
-         == GET_MODE_BITSIZE (GET_MODE (x)))
-       nonzero = 1;
- #endif
        break;

      case TRUNCATE:
--- 8130,8140 ----
*************** nonzero_bits (x, mode)
*** 8272,8278 ****
                low0 = floor_log2 (nz0 & -nz0);
                low1 = floor_log2 (nz1 & -nz1);
              }
! #endif
            result_width = MAX (width0, width1) + 1;
            result_low = MIN (low0, low1);
            break;
--- 8216,8222 ----
                low0 = floor_log2 (nz0 & -nz0);
                low1 = floor_log2 (nz1 & -nz1);
              }
! #endif /* STACK_BIAS */
            result_width = MAX (width0, width1) + 1;
            result_low = MIN (low0, low1);
            break;
*************** num_sign_bit_copies (x, mode)
*** 8477,8483 ****
       register and MODE is wider than the mode of X, we can say nothing
       at all about the high-order bits.  */
        return 1;
! #else
        /* Likewise on machines that do, if the mode of the object is smaller
         than a word and loads of that size don't sign extend, we can say
         nothing about the high order bits.  */
--- 8421,8427 ----
       register and MODE is wider than the mode of X, we can say nothing
       at all about the high-order bits.  */
        return 1;
! #else /* WORD_REGISTER_OPERATIONS */
        /* Likewise on machines that do, if the mode of the object is smaller
         than a word and loads of that size don't sign extend, we can say
         nothing about the high order bits.  */
*************** num_sign_bit_copies (x, mode)
*** 8487,8493 ****
  #endif
          )
        return 1;
! #endif
      }

    switch (code)
--- 8431,8437 ----
  #endif
          )
        return 1;
! #endif /* WORD_REGISTER_OPERATIONS */
      }

    switch (code)
*************** num_sign_bit_copies (x, mode)
*** 8577,8584 ****
           > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
          && LOAD_EXTEND_OP (GET_MODE (SUBREG_REG (x))) == SIGN_EXTEND)
        return num_sign_bit_copies (SUBREG_REG (x), mode);
! #endif
! #endif
        break;

      case SIGN_EXTRACT:
--- 8521,8528 ----
           > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
          && LOAD_EXTEND_OP (GET_MODE (SUBREG_REG (x))) == SIGN_EXTEND)
        return num_sign_bit_copies (SUBREG_REG (x), mode);
! #endif /* LOAD_EXTEND_OP */
! #endif /* WORD_REGISTER_OPERATIONS */
        break;

      case SIGN_EXTRACT:
*************** simplify_comparison (code, pop0, pop1)
*** 10027,10033 ****
          op0 = SUBREG_REG (XEXP (XEXP (op0, 0), 0));
          op1 = SUBREG_REG (XEXP (XEXP (op1, 0), 0));
        }
! #endif

        /* If both operands are the same constant shift, see if we can
ignore the
         shift.  We can if the shift is a rotate or if the bits shifted out of
--- 9971,9977 ----
          op0 = SUBREG_REG (XEXP (XEXP (op0, 0), 0));
          op1 = SUBREG_REG (XEXP (XEXP (op1, 0), 0));
        }
! #endif /* not WORD_REGISTER_OPERATIONS */

        /* If both operands are the same constant shift, see if we can
ignore the
         shift.  We can if the shift is a rotate or if the bits shifted out of
*************** get_last_value_validate (loc, insn, tick
*** 11512,11518 ****

  /* Get the last value assigned to X, if known.  Some registers
     in the value may be replaced with (clobber (const_int 0)) if their value
!    is known longer known reliably.  */

  static rtx
  get_last_value (x)
--- 11456,11462 ----

  /* Get the last value assigned to X, if known.  Some registers
     in the value may be replaced with (clobber (const_int 0)) if their value
!    is no longer known reliably.  */

  static rtx
  get_last_value (x)
*************** distribute_notes (notes, from_insn, i3,
*** 12412,12418 ****
                                = NOTE_INSN_DELETED;
                              NOTE_SOURCE_FILE (cc0_setter) = 0;
                            }
! #endif
                        }
                      /* If the register is both set and used here, put the
                         REG_DEAD note here, but place a REG_UNUSED note
--- 12356,12362 ----
                                = NOTE_INSN_DELETED;
                              NOTE_SOURCE_FILE (cc0_setter) = 0;
                            }
! #endif /* HAVE_cc0 */
                        }
                      /* If the register is both set and used here, put the
                         REG_DEAD note here, but place a REG_UNUSED note



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]