From 944c6d47bfc42bc95f4d213b97f5abe51e4e1c32 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Sun, 10 Nov 2013 10:13:20 +0000 Subject: [PATCH] Simplify mult-to-shift conversion code. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@204629 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/expmed.c | 25 +++---------------------- gcc/simplify-rtx.c | 2 +- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/gcc/expmed.c b/gcc/expmed.c index c3d773e..089a0b5 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -3075,30 +3075,11 @@ expand_mult (enum machine_mode mode, rtx op0, rtx op1, rtx target, else if (CONST_DOUBLE_AS_INT_P (scalar_op1)) #endif { - int p = GET_MODE_PRECISION (mode); int shift = wi::exact_log2 (std::make_pair (scalar_op1, mode)); - /* Perfect power of 2. */ - is_neg = false; + /* Perfect power of 2 (other than 1, which is handled above). */ if (shift > 0) - { - /* Do the shift count trucation against the bitsize, not - the precision. See the comment above - wide-int.c:trunc_shift for details. */ - if (SHIFT_COUNT_TRUNCATED) - shift &= GET_MODE_BITSIZE (mode) - 1; - /* We could consider adding just a move of 0 to target - if the shift >= p */ - if (shift < p) - return expand_shift (LSHIFT_EXPR, mode, op0, - shift, target, unsignedp); - /* Any positive number that fits in a word. */ - coeff = CONST_WIDE_INT_ELT (scalar_op1, 0); - } - else if (wi::sign_mask (std::make_pair (scalar_op1, mode)) == 0) - { - /* Any positive number that fits in a word. */ - coeff = CONST_WIDE_INT_ELT (scalar_op1, 0); - } + return expand_shift (LSHIFT_EXPR, mode, op0, + shift, target, unsignedp); else goto skip_synth; } diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index fb1a27e..c19d709 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2399,7 +2399,7 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode, if (CONST_SCALAR_INT_P (trueop1)) { val = wi::exact_log2 (std::make_pair (trueop1, mode)); - if (val >= 0 && val < GET_MODE_BITSIZE (mode)) + if (val >= 0) return simplify_gen_binary (ASHIFT, mode, op0, GEN_INT (val)); } -- 2.7.4