mirror of
https://github.com/qemu/qemu.git
synced 2024-11-24 11:23:43 +08:00
tcg: Fix out of range shift in deposit optimizations
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 <rth@twiddle.net>
This commit is contained in:
parent
1976cccec8
commit
d998e555d2
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user