Commit 40c5ed5b by Richard Sandiford Committed by Richard Sandiford

machmode.h (GET_MODE_UNIT_PRECISION): New macro.

gcc/
	* machmode.h (GET_MODE_UNIT_PRECISION): New macro.
	* simplify-rtx.c (simplify_truncation): New function,
	extracted from simplify_subreg and (in small part) from
	simplify_unary_operation_1.
	(simplify_unary_operation_1) <TRUNCATE>: Use it.  Remove sign bit
	test for !TRULY_NOOP_TRUNCATION_MODES_P.
	(simplify_subreg): Use simplify_truncate for lowpart subregs
	where both the inner and outer modes are scalar integers.
	* config/mips/mips.c (mips_truncated_op_cost): New function.
	(mips_rtx_costs): Adjust test for BADDU.
	* config/mips/mips.md (*baddu_di<mode>): Push truncates to operands.

From-SVN: r192186
parent ed901e4c
2012-10-07 Richard Sandiford <rdsandiford@googlemail.com>
* machmode.h (GET_MODE_UNIT_PRECISION): New macro.
* simplify-rtx.c (simplify_truncation): New function,
extracted from simplify_subreg and (in small part) from
simplify_unary_operation_1.
(simplify_unary_operation_1) <TRUNCATE>: Use it. Remove sign bit
test for !TRULY_NOOP_TRUNCATION_MODES_P.
(simplify_subreg): Use simplify_truncate for lowpart subregs
where both the inner and outer modes are scalar integers.
* config/mips/mips.c (mips_truncated_op_cost): New function.
(mips_rtx_costs): Adjust test for BADDU.
* config/mips/mips.md (*baddu_di<mode>): Push truncates to operands.
2012-10-07 Jan Hubicka <jh@suse.cz> 2012-10-07 Jan Hubicka <jh@suse.cz>
* ipa-inline-analysis.c (do_estimate_edge_time): Return actual * ipa-inline-analysis.c (do_estimate_edge_time): Return actual
......
...@@ -3557,6 +3557,17 @@ mips_set_reg_reg_cost (enum machine_mode mode) ...@@ -3557,6 +3557,17 @@ mips_set_reg_reg_cost (enum machine_mode mode)
} }
} }
/* Return the cost of an operand X that can be trucated for free.
SPEED says whether we're optimizing for size or speed. */
static int
mips_truncated_op_cost (rtx x, bool speed)
{
if (GET_CODE (x) == TRUNCATE)
x = XEXP (x, 0);
return set_src_cost (x, speed);
}
/* Implement TARGET_RTX_COSTS. */ /* Implement TARGET_RTX_COSTS. */
static bool static bool
...@@ -3937,12 +3948,13 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, ...@@ -3937,12 +3948,13 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED,
case ZERO_EXTEND: case ZERO_EXTEND:
if (outer_code == SET if (outer_code == SET
&& ISA_HAS_BADDU && ISA_HAS_BADDU
&& (GET_CODE (XEXP (x, 0)) == TRUNCATE
|| GET_CODE (XEXP (x, 0)) == SUBREG)
&& GET_MODE (XEXP (x, 0)) == QImode && GET_MODE (XEXP (x, 0)) == QImode
&& GET_CODE (XEXP (XEXP (x, 0), 0)) == PLUS) && GET_CODE (XEXP (x, 0)) == PLUS)
{ {
*total = set_src_cost (XEXP (XEXP (x, 0), 0), speed); rtx plus = XEXP (x, 0);
*total = (COSTS_N_INSNS (1)
+ mips_truncated_op_cost (XEXP (plus, 0), speed)
+ mips_truncated_op_cost (XEXP (plus, 1), speed));
return true; return true;
} }
*total = mips_zero_extend_cost (mode, XEXP (x, 0)); *total = mips_zero_extend_cost (mode, XEXP (x, 0));
......
...@@ -1306,9 +1306,8 @@ ...@@ -1306,9 +1306,8 @@
(define_insn "*baddu_di<mode>" (define_insn "*baddu_di<mode>"
[(set (match_operand:GPR 0 "register_operand" "=d") [(set (match_operand:GPR 0 "register_operand" "=d")
(zero_extend:GPR (zero_extend:GPR
(truncate:QI (plus:QI (truncate:QI (match_operand:DI 1 "register_operand" "d"))
(plus:DI (match_operand:DI 1 "register_operand" "d") (truncate:QI (match_operand:DI 2 "register_operand" "d")))))]
(match_operand:DI 2 "register_operand" "d")))))]
"ISA_HAS_BADDU && TARGET_64BIT" "ISA_HAS_BADDU && TARGET_64BIT"
"baddu\\t%0,%1,%2" "baddu\\t%0,%1,%2"
[(set_attr "alu_type" "add")]) [(set_attr "alu_type" "add")])
......
...@@ -217,6 +217,11 @@ extern const unsigned char mode_inner[NUM_MACHINE_MODES]; ...@@ -217,6 +217,11 @@ extern const unsigned char mode_inner[NUM_MACHINE_MODES];
#define GET_MODE_UNIT_BITSIZE(MODE) \ #define GET_MODE_UNIT_BITSIZE(MODE) \
((unsigned short) (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT)) ((unsigned short) (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT))
#define GET_MODE_UNIT_PRECISION(MODE) \
(GET_MODE_INNER (MODE) == VOIDmode \
? GET_MODE_PRECISION (MODE) \
: GET_MODE_PRECISION (GET_MODE_INNER (MODE)))
/* Get the number of units in the object. */ /* Get the number of units in the object. */
extern const unsigned char mode_nunits[NUM_MACHINE_MODES]; extern const unsigned char mode_nunits[NUM_MACHINE_MODES];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment