Skip to content

Commit

Permalink
target/i386: Fix BLSR and BLSI
Browse files Browse the repository at this point in the history
The implementation of these two instructions was swapped.
At the same time, unify the setup of eflags for the insn group.

Reported-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Message-Id: <20170712192902.15493-1-rth@twiddle.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
rth7680 authored and bonzini committed Jun 28, 2018
1 parent 019288b commit 1367238
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions target/i386/translate.c
Expand Up @@ -4059,34 +4059,26 @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b,
ot = mo_64_32(s->dflag);
gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 0);

tcg_gen_mov_tl(cpu_cc_src, cpu_T0);
switch (reg & 7) {
case 1: /* blsr By,Ey */
tcg_gen_neg_tl(cpu_T1, cpu_T0);
tcg_gen_subi_tl(cpu_T1, cpu_T0, 1);
tcg_gen_and_tl(cpu_T0, cpu_T0, cpu_T1);
gen_op_mov_reg_v(ot, s->vex_v, cpu_T0);
gen_op_update2_cc();
set_cc_op(s, CC_OP_BMILGB + ot);
break;

case 2: /* blsmsk By,Ey */
tcg_gen_mov_tl(cpu_cc_src, cpu_T0);
tcg_gen_subi_tl(cpu_T0, cpu_T0, 1);
tcg_gen_xor_tl(cpu_T0, cpu_T0, cpu_cc_src);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T0);
set_cc_op(s, CC_OP_BMILGB + ot);
tcg_gen_subi_tl(cpu_T1, cpu_T0, 1);
tcg_gen_xor_tl(cpu_T0, cpu_T0, cpu_T1);
break;

case 3: /* blsi By, Ey */
tcg_gen_mov_tl(cpu_cc_src, cpu_T0);
tcg_gen_subi_tl(cpu_T0, cpu_T0, 1);
tcg_gen_and_tl(cpu_T0, cpu_T0, cpu_cc_src);
tcg_gen_mov_tl(cpu_cc_dst, cpu_T0);
set_cc_op(s, CC_OP_BMILGB + ot);
tcg_gen_neg_tl(cpu_T1, cpu_T0);
tcg_gen_and_tl(cpu_T0, cpu_T0, cpu_T1);
break;

default:
goto unknown_op;
}
tcg_gen_mov_tl(cpu_cc_dst, cpu_T0);
gen_op_mov_reg_v(ot, s->vex_v, cpu_T0);
set_cc_op(s, CC_OP_BMILGB + ot);
break;

default:
Expand Down

0 comments on commit 1367238

Please sign in to comment.