[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/14] tcg: Fix out of range shift in deposit optimiz
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PULL 05/14] tcg: Fix out of range shift in deposit optimizations |
Date: |
Tue, 22 Apr 2014 14:05:55 -0700 |
By inspection, for a deposit(x, y, 0, 64), we'd have a shift of (1<<64)
and everything else falls apart. But we can reuse the existing deposit
logic to get this right.
Signed-off-by: Richard Henderson <address@hidden>
---
tcg/optimize.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index 2fb708e..c447062 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -843,9 +843,8 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t
*tcg_opc_ptr,
break;
CASE_OP_32_64(deposit):
- tmp = ((1ull << args[4]) - 1);
- mask = ((temps[args[1]].mask & ~(tmp << args[3]))
- | ((temps[args[2]].mask & tmp) << args[3]));
+ mask = deposit64(temps[args[1]].mask, args[3], args[4],
+ temps[args[2]].mask);
break;
CASE_OP_32_64(or):
@@ -1060,9 +1059,8 @@ static TCGArg *tcg_constant_folding(TCGContext *s,
uint16_t *tcg_opc_ptr,
if (temps[args[1]].state == TCG_TEMP_CONST
&& temps[args[2]].state == TCG_TEMP_CONST) {
s->gen_opc_buf[op_index] = op_to_movi(op);
- tmp = ((1ull << args[4]) - 1);
- tmp = (temps[args[1]].val & ~(tmp << args[3]))
- | ((temps[args[2]].val & tmp) << args[3]);
+ tmp = deposit64(temps[args[1]].val, args[3], args[4],
+ temps[args[2]].val);
tcg_opt_gen_movi(gen_args, args[0], tmp);
gen_args += 2;
args += 5;
--
1.9.0
- [Qemu-devel] [PULL 00/14] tcg generic queue, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 01/14] tcg: Fix warning (1 bit signed bitfield entry) and replace int by bool, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 02/14] tcg: Use "unspecified behavior" for shifts, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 03/14] tcg: Mask shift quantities while folding, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 04/14] tci: Mask shift counts to avoid undefined behavior, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 06/14] tcg: Add TCGType parameter to tcg_target_const_match, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 05/14] tcg: Fix out of range shift in deposit optimizations,
Richard Henderson <=
- [Qemu-devel] [PULL 07/14] tcg-aarch64: Remove w constraint, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 08/14] tcg-ppc64: Use the type parameter to tcg_target_const_match, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 09/14] tcg-sparc: Use the type parameter to tcg_target_const_match, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 10/14] tcg-s390: Remove W constraint, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 12/14] tcg: Use tcg_gen_mulu2_i32 in tcg_gen_muls2_i32, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 11/14] tcg: Relax requirement for mulu2_i32 on 32-bit hosts, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 13/14] tcg: Fix fallback from muls2_i64 to mulu2_i64, Richard Henderson, 2014/04/22
- [Qemu-devel] [PULL 14/14] tcg: Use HOST_WORDS_BIGENDIAN, Richard Henderson, 2014/04/22
- Re: [Qemu-devel] [PULL 00/14] tcg generic queue, Peter Maydell, 2014/04/24