rtl.h (struct rtx_hooks): Add gen_lowpart_no_emit.

2005-03-21  Paolo Bonzini  <bonzini@gnu.org>

	* rtl.h (struct rtx_hooks): Add gen_lowpart_no_emit.
	* rtlhooks.c (gen_lowpart_no_emit_general): New.
	* rtlhooks-def.h (gen_lowpart_no_emit_general): Declare.
	(RTL_HOOKS_GEN_LOWPART_NO_EMIT): New.
	* simplify-rtx.c (simplify_binary_operation_1): Use it.

From-SVN: r96799
This commit is contained in:
Paolo Bonzini 2005-03-21 14:30:51 +00:00 committed by Paolo Bonzini
parent 0a04ccc571
commit 9ce921aba8
5 changed files with 28 additions and 22 deletions

View File

@ -1,3 +1,11 @@
2005-03-21 Paolo Bonzini <bonzini@gnu.org>
* rtl.h (struct rtx_hooks): Add gen_lowpart_no_emit.
* rtlhooks.c (gen_lowpart_no_emit_general): New.
* rtlhooks-def.h (gen_lowpart_no_emit_general): Declare.
(RTL_HOOKS_GEN_LOWPART_NO_EMIT): New.
* simplify-rtx.c (simplify_binary_operation_1): Use it.
2005-03-21 Kazu Hirata <kazu@cs.umass.edu>
* builtins.c (fold_builtin_1): Take decomposed arguments of

View File

@ -2190,6 +2190,7 @@ extern void sms_schedule (FILE *);
struct rtl_hooks
{
rtx (*gen_lowpart) (enum machine_mode, rtx);
rtx (*gen_lowpart_no_emit) (enum machine_mode, rtx);
rtx (*reg_nonzero_bits) (rtx, enum machine_mode, rtx, enum machine_mode,
unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT *);
rtx (*reg_num_sign_bit_copies) (rtx, enum machine_mode, rtx, enum machine_mode,

View File

@ -24,17 +24,20 @@ Boston, MA 02111-1307, USA. */
#include "rtl.h"
#define RTL_HOOKS_GEN_LOWPART gen_lowpart_general
#define RTL_HOOKS_GEN_LOWPART_NO_EMIT gen_lowpart_no_emit_general
#define RTL_HOOKS_REG_NONZERO_REG_BITS reg_nonzero_bits_general
#define RTL_HOOKS_REG_NUM_SIGN_BIT_COPIES reg_num_sign_bit_copies_general
/* The structure is defined in rtl.h. */
#define RTL_HOOKS_INITIALIZER { \
RTL_HOOKS_GEN_LOWPART, \
RTL_HOOKS_GEN_LOWPART_NO_EMIT, \
RTL_HOOKS_REG_NONZERO_REG_BITS, \
RTL_HOOKS_REG_NUM_SIGN_BIT_COPIES, \
}
extern rtx gen_lowpart_general (enum machine_mode, rtx);
extern rtx gen_lowpart_no_emit_general (enum machine_mode, rtx);
extern rtx reg_nonzero_bits_general (rtx, enum machine_mode, rtx,
enum machine_mode,
unsigned HOST_WIDE_INT,

View File

@ -79,6 +79,19 @@ gen_lowpart_general (enum machine_mode mode, rtx x)
}
}
/* Similar to gen_lowpart, but cannot emit any instruction via
copy_to_reg or force_reg. Mainly used in simplify-rtx.c. */
rtx
gen_lowpart_no_emit_general (enum machine_mode mode, rtx x)
{
rtx result = gen_lowpart_common (mode, x);
if (result)
return result;
if (mode != GET_MODE (x) && GET_MODE (x) != VOIDmode)
return gen_lowpart_SUBREG (mode, x);
return x;
}
rtx
reg_num_sign_bit_copies_general (rtx x ATTRIBUTE_UNUSED,
enum machine_mode mode ATTRIBUTE_UNUSED,

View File

@ -1704,15 +1704,7 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
: const0_rtx;
/* x/1 is x. */
if (trueop1 == const1_rtx)
{
/* Handle narrowing UDIV. */
rtx x = gen_lowpart_common (mode, op0);
if (x)
return x;
if (mode != GET_MODE (op0) && GET_MODE (op0) != VOIDmode)
return gen_lowpart_SUBREG (mode, op0);
return op0;
}
return rtl_hooks.gen_lowpart_no_emit (mode, op0);
/* Convert divide by power of two into shift. */
if (GET_CODE (trueop1) == CONST_INT
&& (val = exact_log2 (INTVAL (trueop1))) > 0)
@ -1768,22 +1760,11 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
: const0_rtx;
/* x/1 is x. */
if (trueop1 == const1_rtx)
{
/* Handle narrowing DIV. */
rtx x = gen_lowpart_common (mode, op0);
if (x)
return x;
if (mode != GET_MODE (op0) && GET_MODE (op0) != VOIDmode)
return gen_lowpart_SUBREG (mode, op0);
return op0;
}
return rtl_hooks.gen_lowpart_no_emit (mode, op0);
/* x/-1 is -x. */
if (trueop1 == constm1_rtx)
{
rtx x = gen_lowpart_common (mode, op0);
if (!x)
x = (mode != GET_MODE (op0) && GET_MODE (op0) != VOIDmode)
? gen_lowpart_SUBREG (mode, op0) : op0;
rtx x = rtl_hooks.gen_lowpart_no_emit (mode, op0);
return simplify_gen_unary (NEG, mode, x, mode);
}
}