summaryrefslogtreecommitdiff
path: root/gcc/config/c6x/c6x.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/config/c6x/c6x.c')
-rw-r--r--gcc/config/c6x/c6x.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c
index de49d8b33b9..936161c3d16 100644
--- a/gcc/config/c6x/c6x.c
+++ b/gcc/config/c6x/c6x.c
@@ -6045,11 +6045,12 @@ shift_p (rtx x, enum rtx_code code, int amount)
scanned. In either case, *TOTAL contains the cost result. */
static bool
-c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total,
+c6x_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno, int *total,
bool speed)
{
int cost2 = COSTS_N_INSNS (1);
rtx op0, op1;
+ int code = GET_CODE (x);
switch (code)
{
@@ -6078,12 +6079,12 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total,
case TRUNCATE:
/* Recognize a mult_highpart operation. */
- if ((GET_MODE (x) == HImode || GET_MODE (x) == SImode)
+ if ((mode == HImode || mode == SImode)
&& GET_CODE (XEXP (x, 0)) == LSHIFTRT
- && GET_MODE (XEXP (x, 0)) == GET_MODE_2XWIDER_MODE (GET_MODE (x))
+ && GET_MODE (XEXP (x, 0)) == GET_MODE_2XWIDER_MODE (mode)
&& GET_CODE (XEXP (XEXP (x, 0), 0)) == MULT
&& GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
- && INTVAL (XEXP (XEXP (x, 0), 1)) == GET_MODE_BITSIZE (GET_MODE (x)))
+ && INTVAL (XEXP (XEXP (x, 0), 1)) == GET_MODE_BITSIZE (mode))
{
rtx mul = XEXP (XEXP (x, 0), 0);
rtx op0 = XEXP (mul, 0);
@@ -6093,15 +6094,16 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total,
if ((code0 == code1
&& (code0 == SIGN_EXTEND || code0 == ZERO_EXTEND))
- || (GET_MODE (x) == HImode
+ || (mode == HImode
&& code0 == ZERO_EXTEND && code1 == SIGN_EXTEND))
{
- if (GET_MODE (x) == HImode)
+ if (mode == HImode)
*total = COSTS_N_INSNS (2);
else
*total = COSTS_N_INSNS (12);
- *total += rtx_cost (XEXP (op0, 0), code0, 0, speed);
- *total += rtx_cost (XEXP (op1, 0), code1, 0, speed);
+ mode = GET_MODE (XEXP (op0, 0));
+ *total += rtx_cost (XEXP (op0, 0), mode, code0, 0, speed);
+ *total += rtx_cost (XEXP (op1, 0), mode, code1, 0, speed);
return true;
}
}
@@ -6110,7 +6112,7 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total,
case ASHIFT:
case ASHIFTRT:
case LSHIFTRT:
- if (GET_MODE (x) == DImode)
+ if (mode == DImode)
*total = COSTS_N_INSNS (CONSTANT_P (XEXP (x, 1)) ? 4 : 15);
else
*total = COSTS_N_INSNS (1);
@@ -6121,16 +6123,16 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total,
*total = COSTS_N_INSNS (1);
op0 = code == PLUS ? XEXP (x, 0) : XEXP (x, 1);
op1 = code == PLUS ? XEXP (x, 1) : XEXP (x, 0);
- if (GET_MODE_SIZE (GET_MODE (x)) <= UNITS_PER_WORD
- && INTEGRAL_MODE_P (GET_MODE (x))
+ if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
+ && INTEGRAL_MODE_P (mode)
&& GET_CODE (op0) == MULT
&& GET_CODE (XEXP (op0, 1)) == CONST_INT
&& (INTVAL (XEXP (op0, 1)) == 2
|| INTVAL (XEXP (op0, 1)) == 4
|| (code == PLUS && INTVAL (XEXP (op0, 1)) == 8)))
{
- *total += rtx_cost (XEXP (op0, 0), ASHIFT, 0, speed);
- *total += rtx_cost (op1, (enum rtx_code) code, 1, speed);
+ *total += rtx_cost (XEXP (op0, 0), mode, ASHIFT, 0, speed);
+ *total += rtx_cost (op1, mode, (enum rtx_code) code, 1, speed);
return true;
}
return false;
@@ -6138,21 +6140,21 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total,
case MULT:
op0 = XEXP (x, 0);
op1 = XEXP (x, 1);
- if (GET_MODE (x) == DFmode)
+ if (mode == DFmode)
{
if (TARGET_FP)
*total = COSTS_N_INSNS (speed ? 10 : 1);
else
*total = COSTS_N_INSNS (speed ? 200 : 4);
}
- else if (GET_MODE (x) == SFmode)
+ else if (mode == SFmode)
{
if (TARGET_FP)
*total = COSTS_N_INSNS (speed ? 4 : 1);
else
*total = COSTS_N_INSNS (speed ? 100 : 4);
}
- else if (GET_MODE (x) == DImode)
+ else if (mode == DImode)
{
if (TARGET_MPY32
&& GET_CODE (op0) == GET_CODE (op1)
@@ -6167,7 +6169,7 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total,
/* Maybe improve this laster. */
*total = COSTS_N_INSNS (20);
}
- else if (GET_MODE (x) == SImode)
+ else if (mode == SImode)
{
if (((GET_CODE (op0) == ZERO_EXTEND
|| GET_CODE (op0) == SIGN_EXTEND
@@ -6195,15 +6197,15 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total,
else
*total = COSTS_N_INSNS (6);
}
- else if (GET_MODE (x) == HImode)
+ else if (mode == HImode)
*total = COSTS_N_INSNS (speed ? 2 : 1);
if (GET_CODE (op0) != REG
&& (GET_CODE (op0) != SUBREG || GET_CODE (SUBREG_REG (op0)) != REG))
- *total += rtx_cost (op0, MULT, 0, speed);
+ *total += rtx_cost (op0, mode, MULT, 0, speed);
if (op1 && GET_CODE (op1) != REG
&& (GET_CODE (op1) != SUBREG || GET_CODE (SUBREG_REG (op1)) != REG))
- *total += rtx_cost (op1, MULT, 1, speed);
+ *total += rtx_cost (op1, mode, MULT, 1, speed);
return true;
case UDIV:
@@ -6221,7 +6223,7 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total,
&& XEXP (op0, 1) == const0_rtx
&& rtx_equal_p (XEXP (x, 1), XEXP (op0, 0)))
{
- *total = rtx_cost (XEXP (x, 1), (enum rtx_code) outer_code,
+ *total = rtx_cost (XEXP (x, 1), VOIDmode, (enum rtx_code) outer_code,
opno, speed);
return false;
}