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]

Re: patch: RTL loop optimizer - new target hook in doloop_valid_p


On Thu, Jun 02, 2005 at 10:20:25AM -0400, David Edelsohn wrote:
> 	I have committed the following patch to define the hook for PowerPC.
> 
> 	The one unfortunate aspect of the change is that the hook does not
> have a pointed to the dump file to report why doloop could not be applied.

Sorry for overlooking that. I guess that would be nice to have.
With this patch doloop_valid_p also passes 'dump_file' to the target
hook.  
So far only s390 and rs6000 seem to use the hook, updating them
should not be that difficult.  Comments?

Bye,
Adrian

2005-06-06  Adrian Straetling  <straetling@de.ibm.com>

	* gcc/target.h: (struct gcc_target): Pass FILE * for dump.
	* targhooks.c: (default_insn_valid_within_doloop): New parameter
	'dump'. Use local 'dump' instead of global 'dump_file'. Update
	Comment.
	* targhooks.h: Update "default_insn_valid_within_doloop".
	* loop-doloop.c: (doloop_valid_p): Pass 'dump_file' to hook.
	* docs/tm.texi: Update documentation.

	
Index: gcc/targhooks.c
===================================================================
*** gcc/targhooks.c.orig	2005-06-07 18:20:17.645026268 +0200
--- gcc/targhooks.c	2005-06-07 18:20:30.435026268 +0200
*************** default_scalar_mode_supported_p (enum ma
*** 265,282 ****
  /* TRUE if INSN insn is valid within a low-overhead loop.
    
     This function checks whether a given INSN is valid within a low-overhead
!    loop.  A called function may clobber any special registers required for
     low-overhead looping. Additionally, some targets (eg, PPC) use the count
     register for branch on table instructions. We reject the doloop pattern in
     these cases.  */
  
  bool 
! default_insn_valid_within_doloop (rtx insn)
  {
    if (CALL_P (insn))
      {
!       if (dump_file)
! 	fprintf (dump_file, "Doloop: Function call in loop.\n");
  	return false;
      }
    
--- 265,283 ----
  /* TRUE if INSN insn is valid within a low-overhead loop.
    
     This function checks whether a given INSN is valid within a low-overhead
!    loop. DUMP_FILE points to a dump file to which rejection reasons may be
!    printed.  A called function may clobber any special registers required for
     low-overhead looping. Additionally, some targets (eg, PPC) use the count
     register for branch on table instructions. We reject the doloop pattern in
     these cases.  */
  
  bool 
! default_insn_valid_within_doloop (FILE * dump, rtx insn)
  {
    if (CALL_P (insn))
      {
!       if (dump)
! 	fprintf (dump, "Doloop: Function call in loop.\n");
  	return false;
      }
    
*************** default_insn_valid_within_doloop (rtx in
*** 284,291 ****
        && (GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC
  	  || GET_CODE (PATTERN (insn)) == ADDR_VEC))
      {
!       if (dump_file)
! 	fprintf (dump_file, "Doloop: Computed branch in the loop.\n");
        return false;
      }
    
--- 285,292 ----
        && (GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC
  	  || GET_CODE (PATTERN (insn)) == ADDR_VEC))
      {
!       if (dump)
! 	fprintf (dump, "Doloop: Computed branch in the loop.\n");
        return false;
      }
    
Index: gcc/loop-doloop.c
===================================================================
*** gcc/loop-doloop.c.orig	2005-06-07 18:20:17.645026268 +0200
--- gcc/loop-doloop.c	2005-06-07 18:20:30.435026268 +0200
*************** doloop_valid_p (struct loop *loop, struc
*** 204,210 ****
  	  /* Different targets have different necessities for low-overhead
  	     looping.  Call the back end for each instruction within the loop
  	     to let it decide whether the insn is valid.  */
! 	  if (!targetm.insn_valid_within_doloop (insn))
  	  {
  	      result = false;
  	      goto cleanup;
--- 204,210 ----
  	  /* Different targets have different necessities for low-overhead
  	     looping.  Call the back end for each instruction within the loop
  	     to let it decide whether the insn is valid.  */
! 	  if (!targetm.insn_valid_within_doloop (dump_file, insn))
  	  {
  	      result = false;
  	      goto cleanup;
Index: gcc/targhooks.h
===================================================================
*** gcc/targhooks.h.orig	2005-06-07 18:20:17.645026268 +0200
--- gcc/targhooks.h	2005-06-07 18:20:30.435026268 +0200
*************** extern void default_unwind_emit (FILE *,
*** 46,52 ****
  
  extern bool default_scalar_mode_supported_p (enum machine_mode);
  
! extern bool default_insn_valid_within_doloop (rtx);
  
  /* These are here, and not in hooks.[ch], because not all users of
     hooks.h include tm.h, and thus we don't have CUMULATIVE_ARGS.  */
--- 46,52 ----
  
  extern bool default_scalar_mode_supported_p (enum machine_mode);
  
! extern bool default_insn_valid_within_doloop (FILE *, rtx);
  
  /* These are here, and not in hooks.[ch], because not all users of
     hooks.h include tm.h, and thus we don't have CUMULATIVE_ARGS.  */
Index: gcc/doc/tm.texi
===================================================================
*** gcc/doc/tm.texi.orig	2005-06-07 18:20:17.645026268 +0200
--- gcc/doc/tm.texi	2005-06-07 18:20:30.445026268 +0200
*************** simplified expression for the call's res
*** 9372,9381 ****
  the value will be ignored.
  @end deftypefn
  
! @deftypefn {Target Hook} bool TARGET_INSN_VALID_WITHIN_DOLOOP (rtx @var{insn})
  
  Take an instruction in @var{insn} and return true if it is valid within a
! low-overhead loop.
  
  Many targets use special registers for low-overhead looping. This function
  should return false for any instruction that clobbers these. 
--- 9372,9382 ----
  the value will be ignored.
  @end deftypefn
  
! @deftypefn {Target Hook} bool TARGET_INSN_VALID_WITHIN_DOLOOP (FILE * @var{dump}, rtx @var{insn})
  
  Take an instruction in @var{insn} and return true if it is valid within a
! low-overhead loop. @var{dump} points to the dump file for the hook to report
! why doloop could not be applied.
  
  Many targets use special registers for low-overhead looping. This function
  should return false for any instruction that clobbers these. 
Index: gcc/target.h
===================================================================
*** gcc/target.h.orig	2005-06-07 18:20:17.645026268 +0200
--- gcc/target.h	2005-06-07 18:20:30.455026268 +0200
*************** struct gcc_target
*** 526,532 ****
    bool (*stdarg_optimize_hook) (struct stdarg_info *ai, tree lhs, tree rhs);
  
    /* Returns true if target supports the insn within a doloop block.  */
!   bool (*insn_valid_within_doloop) (rtx);
      
    /* Functions relating to calls - argument passing, returns, etc.  */
    struct calls {
--- 526,532 ----
    bool (*stdarg_optimize_hook) (struct stdarg_info *ai, tree lhs, tree rhs);
  
    /* Returns true if target supports the insn within a doloop block.  */
!   bool (*insn_valid_within_doloop) (FILE *, rtx);
      
    /* Functions relating to calls - argument passing, returns, etc.  */
    struct calls {


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