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 for complex -> component mode simplification


I found 5 places in GCC where we get the component (unit) mode of a
complex type using GET_MODE_UNIT_SIZE and mode_for_size.  It is much
simpler (and faster) to use the GET_MODE_INNER macro.  I suspect that
this macro did not exist when the code in question was first written.

Tested on HP-UX (IA64 and PA).

Steve Ellcey
sje@cup.hp.com


2002-11-19  Steve Ellcey  <sje@cup.hp.com>

	* emit-rtl.c (gen_reg_rtx): Simplify mapping of Complex type
	to component type using GET_MODE_INNER.
	* expr.c (emit_move_insn_1): Ditto.
	* optabs.c (expand_binop): Ditto.
	(expand_unop): Ditto.
	(expand_complex_abs): Ditto.


*** gcc.orig/gcc/emit-rtl.c	Tue Nov 19 15:08:59 2002
--- gcc/gcc/emit-rtl.c	Tue Nov 19 15:10:16 2002
*************** gen_reg_rtx (mode)
*** 802,813 ****
  	 which makes much better code.  Besides, allocating DCmode
  	 pseudos overstrains reload on some machines like the 386.  */
        rtx realpart, imagpart;
!       int size = GET_MODE_UNIT_SIZE (mode);
!       enum machine_mode partmode
! 	= mode_for_size (size * BITS_PER_UNIT,
! 			 (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
! 			  ? MODE_FLOAT : MODE_INT),
! 			 0);
  
        realpart = gen_reg_rtx (partmode);
        imagpart = gen_reg_rtx (partmode);
--- 802,808 ----
  	 which makes much better code.  Besides, allocating DCmode
  	 pseudos overstrains reload on some machines like the 386.  */
        rtx realpart, imagpart;
!       enum machine_mode partmode = GET_MODE_INNER (mode);
  
        realpart = gen_reg_rtx (partmode);
        imagpart = gen_reg_rtx (partmode);
*** gcc.orig/gcc/expr.c	Tue Nov 19 15:11:01 2002
--- gcc/gcc/expr.c	Tue Nov 19 15:11:55 2002
*************** emit_move_insn_1 (x, y)
*** 3152,3162 ****
  
    /* Expand complex moves by moving real part and imag part, if possible.  */
    else if ((class == MODE_COMPLEX_FLOAT || class == MODE_COMPLEX_INT)
! 	   && BLKmode != (submode = mode_for_size ((GET_MODE_UNIT_SIZE (mode)
! 						    * BITS_PER_UNIT),
! 						   (class == MODE_COMPLEX_INT
! 						    ? MODE_INT : MODE_FLOAT),
! 						   0))
  	   && (mov_optab->handlers[(int) submode].insn_code
  	       != CODE_FOR_nothing))
      {
--- 3152,3158 ----
  
    /* Expand complex moves by moving real part and imag part, if possible.  */
    else if ((class == MODE_COMPLEX_FLOAT || class == MODE_COMPLEX_INT)
! 	   && BLKmode != (submode = GET_MODE_INNER (mode))
  	   && (mov_optab->handlers[(int) submode].insn_code
  	       != CODE_FOR_nothing))
      {
*** gcc.orig/gcc/optabs.c	Tue Nov 19 15:12:21 2002
--- gcc/gcc/optabs.c	Tue Nov 19 15:14:25 2002
*************** expand_binop (mode, binoptab, op0, op1, 
*** 1531,1540 ****
        int ok = 0;
  
        /* Find the correct mode for the real and imaginary parts */
!       enum machine_mode submode
! 	= mode_for_size (GET_MODE_UNIT_SIZE (mode) * BITS_PER_UNIT,
! 			 class == MODE_COMPLEX_INT ? MODE_INT : MODE_FLOAT,
! 			 0);
  
        if (submode == BLKmode)
  	abort ();
--- 1531,1537 ----
        int ok = 0;
  
        /* Find the correct mode for the real and imaginary parts */
!       enum machine_mode submode = GET_MODE_INNER(mode);
  
        if (submode == BLKmode)
  	abort ();
*************** expand_unop (mode, unoptab, op0, target,
*** 2484,2493 ****
        rtx seq;
  
        /* Find the correct mode for the real and imaginary parts */
!       enum machine_mode submode
! 	= mode_for_size (GET_MODE_UNIT_SIZE (mode) * BITS_PER_UNIT,
! 			 class == MODE_COMPLEX_INT ? MODE_INT : MODE_FLOAT,
! 			 0);
  
        if (submode == BLKmode)
  	abort ();
--- 2481,2487 ----
        rtx seq;
  
        /* Find the correct mode for the real and imaginary parts */
!       enum machine_mode submode = GET_MODE_INNER (mode);
  
        if (submode == BLKmode)
  	abort ();
*************** expand_complex_abs (mode, op0, target, u
*** 2731,2740 ****
    optab this_abs_optab;
  
    /* Find the correct mode for the real and imaginary parts.  */
!   enum machine_mode submode
!     = mode_for_size (GET_MODE_UNIT_SIZE (mode) * BITS_PER_UNIT,
! 		     class == MODE_COMPLEX_INT ? MODE_INT : MODE_FLOAT,
! 		     0);
  
    if (submode == BLKmode)
      abort ();
--- 2725,2731 ----
    optab this_abs_optab;
  
    /* Find the correct mode for the real and imaginary parts.  */
!   enum machine_mode submode = GET_MODE_INNER (mode);
  
    if (submode == BLKmode)
      abort ();


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