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]
Other format: [Raw text]

[PATCH 0/5] Yet more use of rtx subclasses; possible rl78 bug


Here's another 5 patches that make use of rtx_def subclasses, which
are non-trivial enough *not* to fall under the pre-approval Jeff
granted.

In particular, patches 4 and 5 update the signature of recog_memoized
and single_set respectively to require an rtx_insn * rather than
just an rtx.  These last two patches got rather large; sorry.
single_set becomes an inline function rather than a macro in patch 5.

Doing so uncovered what looks to me like a bug in
rl78_remove_unused_sets.

The existing code had:

  3585  /* Remove any SETs where the destination is unneeded.  */
  3586  static void
  3587  rl78_remove_unused_sets (void)
  3588  {
  3589    rtx insn, ninsn = NULL_RTX;
  3590    rtx dest;
  3591  
  3592    for (insn = get_insns (); insn; insn = ninsn)
  3593      {
  3594        ninsn = next_nonnote_nondebug_insn (insn);
  3595  
  3596        if ((insn = single_set (insn)) == NULL_RTX)
  3597          continue;
  3598  
  3599        dest = SET_DEST (insn);
  3600  
  3601        if (GET_CODE (dest) != REG || REGNO (dest) > 23)
  3602          continue;
  3603  
  3604        if (find_regno_note (insn, REG_UNUSED, REGNO (dest)))
  3605          delete_insn (insn);
  3606      }
  3607  }

Assuming I'm reading this right, note how at line 3604:
  3604        if (find_regno_note (insn, REG_UNUSED, REGNO (dest)))
it calls find_regno_note on "insn", but "insn" was set to the
result of single_set at line 3596:
  3596        if ((insn = single_set (insn)) == NULL_RTX)
i.e. "insn" is now a SET rather than a insn; hence the call to
find_regno_note was presumably always bailing early at line 1875 of
rtlanal.c due to the failed INSN_P test for "insn" being a SET:

  1868  rtx
  1869  find_regno_note (const_rtx insn, enum reg_note kind, unsigned int regno)
  1870  {
  1871    rtx link;
  1872  
  1873    /* Ignore anything that is not an INSN, JUMP_INSN or CALL_INSN.  */
  1874    if (! INSN_P (insn))
  1875      return 0;

hence line 3605 of rl78.c could never be reached:
  3604        if (find_regno_note (insn, REG_UNUSED, REGNO (dest)))
  3605          delete_insn (insn);
and hence I believe rl78_remove_unused_sets doesn't actually do
anything.

I fixed this (in patch 5) by introducing a new local rtx "set" for the
result of single_set, and hence not overwriting "insn" within the loop.
That said I've only tested that it compiles for rl78, I've not yet
forced line 3605 to execute, and not simulated the resulting code.

As before, I've bootstrapped each patch on x86_64-unknown-linux-gnu
(Fedora 20), and rebuilt the entire series as part of a config-list.mk
build, for all working configurations (currently 188 configurations).

OK for trunk?

David Malcolm (5):
  struct ira_reg_equiv_s's "init_insns" is an rtx_insn_list
  Handcode gen_rtx_INSN
  INSN_LOCATION takes an rtx_insn
  recog_memoized works on an rtx_insn *
  single_set takes an insn

 gcc/caller-save.c                    |   4 +-
 gcc/combine.c                        |   7 ++-
 gcc/config/aarch64/aarch64-protos.h  |   2 +-
 gcc/config/aarch64/aarch64.c         |   2 +-
 gcc/config/arc/arc-protos.h          |   4 +-
 gcc/config/arc/arc.c                 |  22 ++++----
 gcc/config/arc/arc.h                 |   4 +-
 gcc/config/arm/aarch-common-protos.h |   2 +-
 gcc/config/arm/aarch-common.c        |  15 +++---
 gcc/config/arm/arm-protos.h          |   6 +--
 gcc/config/arm/arm.c                 |  20 +++----
 gcc/config/avr/avr-protos.h          |   2 +-
 gcc/config/avr/avr.c                 |  11 ++--
 gcc/config/avr/avr.md                |   5 +-
 gcc/config/bfin/bfin.c               |  20 +++----
 gcc/config/c6x/c6x.c                 |  24 +++++----
 gcc/config/cris/cris.c               |   2 +-
 gcc/config/cris/cris.md              |   2 +-
 gcc/config/frv/frv-protos.h          |   2 +-
 gcc/config/frv/frv.c                 |  12 ++---
 gcc/config/h8300/h8300-protos.h      |   2 +-
 gcc/config/h8300/h8300.c             |   2 +-
 gcc/config/i386/i386-protos.h        |  10 ++--
 gcc/config/i386/i386.c               |  25 +++++----
 gcc/config/ia64/ia64-protos.h        |   4 +-
 gcc/config/ia64/ia64.c               |  44 +++++++--------
 gcc/config/ia64/ia64.md              |   3 +-
 gcc/config/m68k/m68k-protos.h        |   4 +-
 gcc/config/m68k/m68k.c               |  18 +++----
 gcc/config/m68k/m68k.h               |   4 +-
 gcc/config/mep/mep.c                 |   7 ++-
 gcc/config/mips/mips-protos.h        |   8 +--
 gcc/config/mips/mips.c               |  34 ++++++------
 gcc/config/mn10300/mn10300.c         |  25 ++++-----
 gcc/config/pa/pa-protos.h            |   2 +-
 gcc/config/pa/pa.c                   |  12 ++---
 gcc/config/rl78/rl78.c               |  26 ++++-----
 gcc/config/rs6000/rs6000-protos.h    |   2 +-
 gcc/config/rs6000/rs6000.c           |   6 +--
 gcc/config/s390/predicates.md        |   2 +-
 gcc/config/s390/s390-protos.h        |   2 +-
 gcc/config/s390/s390.c               |  29 +++++-----
 gcc/config/sh/sh-protos.h            |   2 +-
 gcc/config/sh/sh.c                   |  13 ++---
 gcc/config/sh/sh.md                  |  15 ++++--
 gcc/config/sh/sh_treg_combine.cc     |  12 ++---
 gcc/config/sparc/sparc.c             |   9 ++--
 gcc/config/stormy16/stormy16.c       |   7 +--
 gcc/config/tilegx/tilegx.c           |   2 +-
 gcc/dwarf2cfi.c                      |  20 +++----
 gcc/dwarf2out.c                      |   5 +-
 gcc/emit-rtl.c                       |  21 ++++++--
 gcc/emit-rtl.h                       |   2 +-
 gcc/expr.c                           |   2 +-
 gcc/final.c                          |   7 +--
 gcc/gcse.c                           |   4 +-
 gcc/genattr.c                        |   2 +-
 gcc/genattrtab.c                     |   2 +-
 gcc/gengenrtl.c                      |   1 +
 gcc/hw-doloop.h                      |   2 +-
 gcc/ifcvt.c                          | 101 ++++++++++++++++++-----------------
 gcc/ira-int.h                        |   2 +-
 gcc/ira.c                            |  25 +++++----
 gcc/ira.h                            |   2 +-
 gcc/lra-assigns.c                    |   6 +--
 gcc/lra-constraints.c                |  46 ++++++++--------
 gcc/lra.c                            |  38 +++++++------
 gcc/modulo-sched.c                   |   5 +-
 gcc/postreload-gcse.c                |   5 +-
 gcc/print-rtl.c                      |   6 ++-
 gcc/recog.c                          |  27 +++++-----
 gcc/recog.h                          |  16 +++---
 gcc/reload.c                         |   6 ++-
 gcc/reload.h                         |   2 +-
 gcc/reload1.c                        |   6 +--
 gcc/reorg.c                          |  14 ++---
 gcc/rtl.h                            |  43 +++++++++------
 gcc/rtlanal.c                        |   2 +-
 gcc/sel-sched-ir.c                   |   2 +-
 gcc/sel-sched.c                      |   2 +-
 gcc/store-motion.c                   |  11 ++--
 81 files changed, 495 insertions(+), 439 deletions(-)

-- 
1.8.5.3


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