diff options
author | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-21 14:30:51 +0000 |
---|---|---|
committer | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-21 14:30:51 +0000 |
commit | 8666c3913a18243341907aa05523d93f97d5610f (patch) | |
tree | 681954762b33192c42f1a60a5211b189369f90af | |
parent | 9a5f6cddc29f9ac3fdeab67a4001d9fcb432f56c (diff) | |
download | gcc-8666c3913a18243341907aa05523d93f97d5610f.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96799 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/rtl.h | 1 | ||||
-rw-r--r-- | gcc/rtlhooks-def.h | 3 | ||||
-rw-r--r-- | gcc/rtlhooks.c | 13 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 25 |
5 files changed, 28 insertions, 22 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e12efca9ff7..0d36343d2fe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/rtl.h b/gcc/rtl.h index cb3cb87578f..ba3277f6917 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -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, diff --git a/gcc/rtlhooks-def.h b/gcc/rtlhooks-def.h index aaae80cab8c..cd9cd52d0f0 100644 --- a/gcc/rtlhooks-def.h +++ b/gcc/rtlhooks-def.h @@ -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, diff --git a/gcc/rtlhooks.c b/gcc/rtlhooks.c index 49d4cfe7c59..5303af54716 100644 --- a/gcc/rtlhooks.c +++ b/gcc/rtlhooks.c @@ -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, diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 2f7ae25c57e..a7033315e98 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -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); } } |