patch to fix SH4 mode-switching problems

Jeffrey A Law law@cygnus.com
Sun Feb 6 23:18:00 GMT 2000


  In message <200001192320.XAA05002@phal.cygnus.co.uk>you write:
  > Here is the version of the patch that uses new machine-independent
  > code in lcm.c:
  > 
  > Wed Jan 19 23:05:04 2000  J"orn Rennecke <amylaar@cygnus.co.uk>
  >                           Andrew MacLeod  <amacleod@cygnus.com>
  > 
  > 	* Makefile.in (lcm.o): Depend on insn-attr.h.
  > 	* basic-block.h (optimize_mode_switching): Declare.
  > 	* lcm.c (tm_p.h, insn-attr.h): #include.
  >         (seginfo, bb_info): New structs.
  >         (antic, transp, comp, delete, insert) : New file-scope static varia
  > bles.
  >         (new_seginfo, add_seginfo, make_preds_opaque, reg_dies): New functi
  > ons.
  > 	(reg_becomes_live, optimize_mode_switching): Likewise.
  > 	* tm.texi: Add description of mode switching macros.
  >         * toplev.c (rest_of_compilation): Call optimize_mode_switching.
  > 
  > 	* sh-protos.h (remove_dead_before_cse): Remove prototype.
  > 	(fldi_ok, fpscr_set_from_mem): New prototypes.
  >         * sh.h (OPTIMIZATION_OPTION): Remove sh_flag_remove_dead_before_cse
  >  set.
  >         (CONST_DOUBLE_OK_FOR_LETTER_P, SECONDARY_INPUT_RELOAD_CLASS):
  > 	Disable fldi for (TARGET_SH4 && ! TARGET_FMOVD).
  > 	(sh_flag_remove_dead_before_cse): Remove declaration.
  > 	(NUM_MODES_FOR_MODE_SWITCHING, OPTIMIZE_MODE_SWITCHING): New macros.
  > 	(MODE_USES_IN_EXIT_BLOCK, MODE_NEEDED, MODE_AT_ENTRY): Likewise.
  > 	(MODE_PRIORITY_TO_MODE, EMIT_MODE_SET): Likewise.
  >         * sh.c (broken_move): Disable fldi for (TARGET_SH4 && ! TARGET_FMOV
  > D).
  >         (barrier_align): Allow for JUMP_INSNS containing a parallel.
  > 	(machine_dependent_reorg): Remove sh_flag_remove_dead_before_cse set.
  > 	(fldi_ok): New function.
  > 	(get_fpscr_rtx): Add fpscr_rtx as GC root.
  >         (emit_sf_insn): Only generate fpu switches when optimize < 1.
  >         (emit_df_insn): Likewise.
  >         (expand_fp_branch, emit_fpscr_use, remove_dead_before_cse): Delete.
  > 	(sh_flag_remove_dead_before_cse): Delete.
  >         (get_free_reg, fpscr_set_from_mem): New functions.
  >         * sh.md (movdf, movsf): Remove no_new_pseudos code.
  > 	(return): Remove emit_fpscr_use / remove_dead_before_cse calls.
Thanks.  This looks a lot better.  Just a few minor nits.


In optimize_mode_switching we search for uses of the return value.  Is that
code still needed?

  > + static void
  > + make_preds_opaque (b, j)
  > +      basic_block b;
  > +      int j;
  > + {
  > +   edge e;
  > + 
  > +   for (e = b->pred; e; e = e->pred_next)
  > +     {
  > +       basic_block pb = e->src;
  > +       if (e->aux || ! TEST_BIT (transp[pb->index], j))
  > + 	continue;
  > +       RESET_BIT (transp[pb->index], j);
  > +       make_preds_opaque (pb, j);
  > +     }
  > + }
What is the point behind checking e->aux?  If it's just to avoid losing
the head of the edge is the entry block, then we should just check for that
directly.

  > +    This is called via note_stores.  */
  > + static void
  > + reg_becomes_live (reg, setter, live)
  > +      rtx reg;
  > +      rtx setter ATTRIBUTE_UNUSED;
  > +      void *live;
  > + {
  > +   int regno;
  > + 
  > +   if (GET_CODE (reg) == SUBREG)
  > +     reg = SUBREG_REG (reg);
Shouldn't this be a while loop?  Do we need similar code in reg_dies?

  > + @node Mode Switching
  > + @section Mode Switching Instructions
  > + @cindex mode switching
  > + The following macros control mode switching optimizations:
Assume I'm writing a new backend.  When would I want to define these macros?
That answer should be included in this section so that developers will know
situations where this code would be useful.

You can either describe it at a high level, or use the SH stuff as an
example.

The patch looks fine otherwise.

jeff



More information about the Gcc-patches mailing list