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]

[Committed] Make expand_mult_highpart static


This "obvious" clean-up is the first step towards resolving PR
middle-end/17958.  This part makes the function expand_mult_highpart
local to expmed.c (it's no longer used outside this file), and changes
the constant multiplier argument, CNST1, from an unsigned HOST_WIDE_INT
to an rtx (which is consistent with the rest of the RTL expanders).

Don't worry about the duplication of gen_int_mode, this will be cleaned
up in a follow-up patch to change choose_multiplier to return an rtx
instead of an unsigned HOST_WIDE_INT.

The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all default languages, and regression tested with a
top-level "make -k check" with no new failures.



2005-01-23  Roger Sayle  <roger@eyesopen.com>

	* expmed.c (expand_mult_highpart): Make static.  Change type of
	constant multiplier argument from unsigned HOST_WIDE_INT to rtx.
	(expand_divmod): Updates calls to expand_mult_highpart by using
	gen_int_mode to pass a CONST_INT rtx.
	* rtl.h (expand_mult_highpart): Remove prototype.


Index: expmed.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expmed.c,v
retrieving revision 1.214
diff -c -3 -p -r1.214 expmed.c
*** expmed.c	10 Dec 2004 15:06:52 -0000	1.214
--- expmed.c	23 Jan 2005 20:44:21 -0000
*************** static unsigned HOST_WIDE_INT choose_mul
*** 2389,2394 ****
--- 2389,2395 ----
  						 int *, int *);
  static unsigned HOST_WIDE_INT invert_mod2n (unsigned HOST_WIDE_INT, int);
  static rtx extract_high_half (enum machine_mode, rtx);
+ static rtx expand_mult_highpart (enum machine_mode, rtx, rtx, rtx, int, int);
  static rtx expand_mult_highpart_optab (enum machine_mode, rtx, rtx, rtx,
  				       int, int);
  /* Compute and return the best algorithm for multiplying by T.
*************** expand_mult_highpart_optab (enum machine
*** 3359,3367 ****
    return 0;
  }

! /* Emit code to multiply OP0 and CNST1, putting the high half of the result
!    in TARGET if that is convenient, and return where the result is.  If the
!    operation can not be performed, 0 is returned.

     MODE is the mode of operation and result.

--- 3360,3369 ----
    return 0;
  }

! /* Emit code to multiply OP0 and OP1 (where OP1 is an integer constant),
!    putting the high half of the result in TARGET if that is convenient,
!    and return where the result is.  If the operation can not be performed,
!    0 is returned.

     MODE is the mode of operation and result.

*************** expand_mult_highpart_optab (enum machine
*** 3369,3391 ****

     MAX_COST is the total allowed cost for the expanded RTL.  */

! rtx
! expand_mult_highpart (enum machine_mode mode, rtx op0,
! 		      unsigned HOST_WIDE_INT cnst1, rtx target,
! 		      int unsignedp, int max_cost)
  {
    enum machine_mode wider_mode = GET_MODE_WIDER_MODE (mode);
    int extra_cost;
    bool sign_adjust = false;
    enum mult_variant variant;
    struct algorithm alg;
!   rtx op1, tem;

    /* We can't support modes wider than HOST_BITS_PER_INT.  */
    gcc_assert (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT);

!   op1 = gen_int_mode (cnst1, wider_mode);
!   cnst1 &= GET_MODE_MASK (mode);

    /* We can't optimize modes wider than BITS_PER_WORD.
       ??? We might be able to perform double-word arithmetic if
--- 3371,3392 ----

     MAX_COST is the total allowed cost for the expanded RTL.  */

! static rtx
! expand_mult_highpart (enum machine_mode mode, rtx op0, rtx op1,
! 		      rtx target, int unsignedp, int max_cost)
  {
    enum machine_mode wider_mode = GET_MODE_WIDER_MODE (mode);
+   unsigned HOST_WIDE_INT cnst1;
    int extra_cost;
    bool sign_adjust = false;
    enum mult_variant variant;
    struct algorithm alg;
!   rtx tem;

    /* We can't support modes wider than HOST_BITS_PER_INT.  */
    gcc_assert (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT);

!   cnst1 = INTVAL (op1) & GET_MODE_MASK (mode);

    /* We can't optimize modes wider than BITS_PER_WORD.
       ??? We might be able to perform double-word arithmetic if
*************** expand_divmod (int rem_flag, enum tree_c
*** 3916,3922 ****
  			      = (shift_cost[compute_mode][post_shift - 1]
  				 + shift_cost[compute_mode][1]
  				 + 2 * add_cost[compute_mode]);
! 			    t1 = expand_mult_highpart (compute_mode, op0, ml,
  						       NULL_RTX, 1,
  						       max_cost - extra_cost);
  			    if (t1 == 0)
--- 3917,3924 ----
  			      = (shift_cost[compute_mode][post_shift - 1]
  				 + shift_cost[compute_mode][1]
  				 + 2 * add_cost[compute_mode]);
! 			    t1 = gen_int_mode (ml, compute_mode);
! 			    t1 = expand_mult_highpart (compute_mode, op0, t1,
  						       NULL_RTX, 1,
  						       max_cost - extra_cost);
  			    if (t1 == 0)
*************** expand_divmod (int rem_flag, enum tree_c
*** 3951,3957 ****
  			    extra_cost
  			      = (shift_cost[compute_mode][pre_shift]
  				 + shift_cost[compute_mode][post_shift]);
! 			    t2 = expand_mult_highpart (compute_mode, t1, ml,
  						       NULL_RTX, 1,
  						       max_cost - extra_cost);
  			    if (t2 == 0)
--- 3953,3960 ----
  			    extra_cost
  			      = (shift_cost[compute_mode][pre_shift]
  				 + shift_cost[compute_mode][post_shift]);
! 			    t2 = gen_int_mode (ml, compute_mode);
! 			    t2 = expand_mult_highpart (compute_mode, t1, t2,
  						       NULL_RTX, 1,
  						       max_cost - extra_cost);
  			    if (t2 == 0)
*************** expand_divmod (int rem_flag, enum tree_c
*** 4072,4078 ****
  			extra_cost = (shift_cost[compute_mode][post_shift]
  				      + shift_cost[compute_mode][size - 1]
  				      + add_cost[compute_mode]);
! 			t1 = expand_mult_highpart (compute_mode, op0, ml,
  						   NULL_RTX, 0,
  						   max_cost - extra_cost);
  			if (t1 == 0)
--- 4075,4082 ----
  			extra_cost = (shift_cost[compute_mode][post_shift]
  				      + shift_cost[compute_mode][size - 1]
  				      + add_cost[compute_mode]);
! 			t1 = gen_int_mode (ml, compute_mode);
! 			t1 = expand_mult_highpart (compute_mode, op0, t1,
  						   NULL_RTX, 0,
  						   max_cost - extra_cost);
  			if (t1 == 0)
*************** expand_divmod (int rem_flag, enum tree_c
*** 4108,4114 ****
  			extra_cost = (shift_cost[compute_mode][post_shift]
  				      + shift_cost[compute_mode][size - 1]
  				      + 2 * add_cost[compute_mode]);
! 			t1 = expand_mult_highpart (compute_mode, op0, ml,
  						   NULL_RTX, 0,
  						   max_cost - extra_cost);
  			if (t1 == 0)
--- 4112,4119 ----
  			extra_cost = (shift_cost[compute_mode][post_shift]
  				      + shift_cost[compute_mode][size - 1]
  				      + 2 * add_cost[compute_mode]);
! 			t1 = gen_int_mode (ml, compute_mode);
! 			t1 = expand_mult_highpart (compute_mode, op0, t1,
  						   NULL_RTX, 0,
  						   max_cost - extra_cost);
  			if (t1 == 0)
*************** expand_divmod (int rem_flag, enum tree_c
*** 4202,4208 ****
  			extra_cost = (shift_cost[compute_mode][post_shift]
  				      + shift_cost[compute_mode][size - 1]
  				      + 2 * add_cost[compute_mode]);
! 			t3 = expand_mult_highpart (compute_mode, t2, ml,
  						   NULL_RTX, 1,
  						   max_cost - extra_cost);
  			if (t3 != 0)
--- 4207,4214 ----
  			extra_cost = (shift_cost[compute_mode][post_shift]
  				      + shift_cost[compute_mode][size - 1]
  				      + 2 * add_cost[compute_mode]);
! 			t3 = gen_int_mode (ml, compute_mode);
! 			t3 = expand_mult_highpart (compute_mode, t2, t3,
  						   NULL_RTX, 1,
  						   max_cost - extra_cost);
  			if (t3 != 0)
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.533
diff -c -3 -p -r1.533 rtl.h
*** rtl.h	20 Jan 2005 11:03:23 -0000	1.533
--- rtl.h	23 Jan 2005 20:44:22 -0000
*************** extern void dump_flow_info (FILE *);
*** 2028,2035 ****
  extern void init_expmed (void);
  extern void expand_inc (rtx, rtx);
  extern void expand_dec (rtx, rtx);
- extern rtx expand_mult_highpart (enum machine_mode, rtx,
- 				 unsigned HOST_WIDE_INT, rtx, int, int);

  /* In gcse.c */
  extern bool can_copy_p (enum machine_mode);
--- 2028,2033 ----


Roger
--


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