diff options
author | Paolo Bonzini <bonzini@gnu.org> | 2005-03-21 14:30:51 +0000 |
---|---|---|
committer | Paolo Bonzini <bonzini@gcc.gnu.org> | 2005-03-21 14:30:51 +0000 |
commit | 9ce921aba837a0775de9abb3ea97e57d30f25e1f (patch) | |
tree | 681954762b33192c42f1a60a5211b189369f90af | |
parent | 0a04ccc5712075b82b95dec4f52b4e9dc3303cd1 (diff) | |
download | gcc-9ce921aba837a0775de9abb3ea97e57d30f25e1f.zip gcc-9ce921aba837a0775de9abb3ea97e57d30f25e1f.tar.gz gcc-9ce921aba837a0775de9abb3ea97e57d30f25e1f.tar.bz2 |
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
-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 e12efca..0d36343 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 @@ -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 aaae80c..cd9cd52 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 49d4cfe..5303af5 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 2f7ae25..a703331 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); } } |