This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Compute mulwiden costs exactly on i386
- From: Bonzini <bonzini at gnu dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 8 Mar 2004 02:49:30 -0500
- Subject: [PATCH] Compute mulwiden costs exactly on i386
On i386, a 32x32->64 multiply costs like a 32bit multiply, not a 64bit
one. This is done by recognizing the (mul (zero_extend ...)
(zero_extend ...)) pattern.
Paolo
2004-02-12 Paolo Bonzini <bonzini@gnu.org>
* config/i386/i386.c (rtx_costs): compute correctly the
cost of a widening multiplication.
Index: i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.646
diff -c -r1.646 i386.c
*** i386.c 8 Feb 2004 23:08:40 -0000 1.646
--- i386.c 13 Feb 2004 13:54:08 -0000
***************
*** 15089,15113 ****
case MULT:
if (FLOAT_MODE_P (mode))
! *total = COSTS_N_INSNS (ix86_cost->fmul);
! else if (GET_CODE (XEXP (x, 1)) == CONST_INT)
{
! unsigned HOST_WIDE_INT value = INTVAL (XEXP (x, 1));
int nbits;
! for (nbits = 0; value != 0; value >>= 1)
! nbits++;
*total = COSTS_N_INSNS (ix86_cost->mult_init[MODE_INDEX (mode)]
! + nbits * ix86_cost->mult_bit);
! }
! else
! {
! /* This is arbitrary */
! *total = COSTS_N_INSNS (ix86_cost->mult_init[MODE_INDEX (mode)]
! + 7 * ix86_cost->mult_bit);
}
- return false;
case DIV:
case UDIV:
--- 15089,15131 ----
case MULT:
if (FLOAT_MODE_P (mode))
! {
! *total = COSTS_N_INSNS (ix86_cost->fmul);
! return false;
! }
! else
{
! rtx op0 = XEXP (x, 0);
! rtx op1 = XEXP (x, 1);
int nbits;
! if (GET_CODE (op1) == CONST_INT)
! {
! unsigned HOST_WIDE_INT value = INTVAL (XEXP (x, 1));
! for (nbits = 0; value != 0; value &= value - 1)
! nbits++;
! }
! else
! /* This is arbitrary */
! nbits = 7;
!
! /* Compute costs correctly for widening multiplication. */
! if ((GET_CODE (op0) == SIGN_EXTEND || GET_CODE (op1) == ZERO_EXTEND)
! && GET_CODE (op0) == GET_CODE (op1)
! && GET_MODE_SIZE (GET_MODE (XEXP (op0, 0))) * 2
! == GET_MODE_SIZE (mode))
! {
! op0 = XEXP (op0, 0);
! op1 = XEXP (op1, 0);
! mode = GET_MODE (op0);
! }
*total = COSTS_N_INSNS (ix86_cost->mult_init[MODE_INDEX (mode)]
! + nbits * ix86_cost->mult_bit)
! + rtx_cost (op0, outer_code) + rtx_cost (op1, outer_code);
!
! return true;
}
case DIV:
case UDIV: