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]

Speedup invalid_mode_change_p


Hi,
this patch saves 5-10% of nonoptimizing combine.c compilation time.
I will try to figure out from where the zillions of
invalid_mode_change_p comes from and cut this down as an followup too.

Thu Feb 27 13:04:08 CET 2003  Jan Hubicka  <jh at suse dot cz>
	* combine.c (gen_lowpart_for_combine): Update handling of subregs_of_mode
	* flow.c (life_analysis, mark_used_regs): Likewise.
	* regclass.c (subregs_of_mode): Turn into single bitmap.
	(cannot_change-mode_set_regs, invalid_mode_change_p): Update
	dealing with subregs_of_mode
	* regs.h (subregs_of_mode): Update prototype.
Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.323.2.12
diff -c -3 -p -r1.323.2.12 combine.c
*** combine.c	24 Feb 2003 21:15:09 -0000	1.323.2.12
--- combine.c	27 Feb 2003 12:03:43 -0000
*************** gen_lowpart_for_combine (mode, x)
*** 10190,10197 ****
        && GET_CODE (result) == SUBREG
        && GET_CODE (SUBREG_REG (result)) == REG
        && REGNO (SUBREG_REG (result)) >= FIRST_PSEUDO_REGISTER)
!     SET_REGNO_REG_SET (&subregs_of_mode[GET_MODE (result)],
! 		       REGNO (SUBREG_REG (result)));
  #endif
  
    if (result)
--- 10190,10198 ----
        && GET_CODE (result) == SUBREG
        && GET_CODE (SUBREG_REG (result)) == REG
        && REGNO (SUBREG_REG (result)) >= FIRST_PSEUDO_REGISTER)
!     bitmap_set_bit (&subregs_of_mode, REGNO (SUBREG_REG (result))
! 				      * MAX_MACHINE_MODE
! 				      + GET_MODE (result));
  #endif
  
    if (result)
Index: flow.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flow.c,v
retrieving revision 1.540.2.1
diff -c -3 -p -r1.540.2.1 flow.c
*** flow.c	14 Dec 2002 22:06:05 -0000	1.540.2.1
--- flow.c	27 Feb 2003 12:03:43 -0000
*************** life_analysis (f, file, flags)
*** 433,441 ****
  
  
  #ifdef CANNOT_CHANGE_MODE_CLASS
!   if (flags & PROP_REG_INFO)
!     for (i=0; i < NUM_MACHINE_MODES; ++i)
!       INIT_REG_SET (&subregs_of_mode[i]);
  #endif
  
    if (! optimize)
--- 433,439 ----
  
  
  #ifdef CANNOT_CHANGE_MODE_CLASS
!   bitmap_initialize (&subregs_of_mode, 1);
  #endif
  
    if (! optimize)
*************** mark_used_regs (pbi, x, cond, insn)
*** 3823,3830 ****
  #ifdef CANNOT_CHANGE_MODE_CLASS
        if (GET_CODE (SUBREG_REG (x)) == REG
  	  && REGNO (SUBREG_REG (x)) >= FIRST_PSEUDO_REGISTER)
! 	SET_REGNO_REG_SET (&subregs_of_mode[GET_MODE (x)],
! 			   REGNO (SUBREG_REG (x)));
  #endif
  
        /* While we're here, optimize this case.  */
--- 3821,3829 ----
  #ifdef CANNOT_CHANGE_MODE_CLASS
        if (GET_CODE (SUBREG_REG (x)) == REG
  	  && REGNO (SUBREG_REG (x)) >= FIRST_PSEUDO_REGISTER)
! 	bitmap_set_bit (&subregs_of_mode, REGNO (SUBREG_REG (x))
! 					  * MAX_MACHINE_MODE
! 					  + GET_MODE (x));
  #endif
  
        /* While we're here, optimize this case.  */
*************** mark_used_regs (pbi, x, cond, insn)
*** 3872,3879 ****
  	    if (GET_CODE (testreg) == SUBREG
  		&& GET_CODE (SUBREG_REG (testreg)) == REG
  		&& REGNO (SUBREG_REG (testreg)) >= FIRST_PSEUDO_REGISTER)
! 	      SET_REGNO_REG_SET (&subregs_of_mode[GET_MODE (testreg)],
! 				 REGNO (SUBREG_REG (testreg)));
  #endif
  
  	    /* Modifying a single register in an alternate mode
--- 3871,3879 ----
  	    if (GET_CODE (testreg) == SUBREG
  		&& GET_CODE (SUBREG_REG (testreg)) == REG
  		&& REGNO (SUBREG_REG (testreg)) >= FIRST_PSEUDO_REGISTER)
! 	      bitmap_set_bit (&subregs_of_mode, REGNO (SUBREG_REG (testreg))
! 						* MAX_MACHINE_MODE
! 						+ GET_MODE (testreg));
  #endif
  
  	    /* Modifying a single register in an alternate mode
Index: regclass.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/regclass.c,v
retrieving revision 1.160.2.4
diff -c -3 -p -r1.160.2.4 regclass.c
*** regclass.c	21 Feb 2003 23:15:44 -0000	1.160.2.4
--- regclass.c	27 Feb 2003 12:03:43 -0000
*************** static char *in_inc_dec;
*** 229,237 ****
  #endif /* FORBIDDEN_INC_DEC_CLASSES */
  
  #ifdef CANNOT_CHANGE_MODE_CLASS
! /* All registers that have been subreged.  Indexed by mode, where each
!    entry is a regset of registers.  */
! regset_head subregs_of_mode [NUM_MACHINE_MODES];
  #endif
  
  /* Sample MEM values for use by memory_move_secondary_cost.  */
--- 229,237 ----
  #endif /* FORBIDDEN_INC_DEC_CLASSES */
  
  #ifdef CANNOT_CHANGE_MODE_CLASS
! /* All registers that have been subreged.  Indexed by regno * MAX_MACHINE_MODE
!    + mode.  */
! bitmap_head subregs_of_mode;
  #endif
  
  /* Sample MEM values for use by memory_move_secondary_cost.  */
*************** cannot_change_mode_set_regs (used, from,
*** 2624,2639 ****
       unsigned int regno;
  {
    enum machine_mode to;
  
!   for (to = VOIDmode; to < MAX_MACHINE_MODE; ++to)
!     if (REGNO_REG_SET_P (&subregs_of_mode[to], regno))
!       {
! 	int i;
! 	for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
!           if (! TEST_HARD_REG_BIT (*used, i)
! 	      && REG_CANNOT_CHANGE_MODE_P (i, from, to))
! 	    SET_HARD_REG_BIT (*used, i);
!       }
  }
  
  /* Return 1 if REGNO has had an invalid mode change in CLASS from FROM
--- 2624,2641 ----
       unsigned int regno;
  {
    enum machine_mode to;
+   int n, i;
+   int start = regno * MAX_MACHINE_MODE;
  
!   EXECUTE_IF_SET_IN_BITMAP (&subregs_of_mode, start, n,
!     if (n >= MAX_MACHINE_MODE + start)
!       return;
!     to = n - start;
!     for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
!       if (! TEST_HARD_REG_BIT (*used, i)
! 	  && REG_CANNOT_CHANGE_MODE_P (i, from, to))
! 	SET_HARD_REG_BIT (*used, i);
!   );
  }
  
  /* Return 1 if REGNO has had an invalid mode change in CLASS from FROM
*************** invalid_mode_change_p (regno, class, fro
*** 2646,2656 ****
       enum machine_mode from_mode;
  {
    enum machine_mode to_mode;
  
!   for (to_mode = 0; to_mode < NUM_MACHINE_MODES; ++to_mode)
!     if (REGNO_REG_SET_P (&subregs_of_mode[(int) to_mode], regno)
! 	&& CANNOT_CHANGE_MODE_CLASS (from_mode, to_mode, class))
        return 1;
    return 0;
  }
  #endif /* CANNOT_CHANGE_MODE_CLASS */
--- 2648,2663 ----
       enum machine_mode from_mode;
  {
    enum machine_mode to_mode;
+   int n;
+   int start = regno * MAX_MACHINE_MODE;
  
!   EXECUTE_IF_SET_IN_BITMAP (&subregs_of_mode, start, n,
!     if (n >= MAX_MACHINE_MODE + start)
!       return 0;
!     to_mode = n - start;
!     if (CANNOT_CHANGE_MODE_CLASS (from_mode, to_mode, class))
        return 1;
+   );
    return 0;
  }
  #endif /* CANNOT_CHANGE_MODE_CLASS */
Index: regs.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/regs.h,v
retrieving revision 1.26
diff -c -3 -p -r1.26 regs.h
*** regs.h	4 Nov 2002 16:57:02 -0000	1.26
--- regs.h	27 Feb 2003 12:03:43 -0000
*************** typedef struct reg_info_def
*** 66,72 ****
  
  extern varray_type reg_n_info;
  
! extern regset_head subregs_of_mode [NUM_MACHINE_MODES];
  
  /* Indexed by n, gives number of times (REG n) is used or set.  */
  
--- 66,72 ----
  
  extern varray_type reg_n_info;
  
! extern bitmap_head subregs_of_mode;
  
  /* Indexed by n, gives number of times (REG n) is used or set.  */
  


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