Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tcg/i386: Use shift in tcg_out_setcond
For LT/GE vs zero, shift down the sign bit.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Aug 24, 2023
1 parent 96658ac commit e91f015
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tcg/i386/tcg-target.c.inc
Expand Up @@ -1578,6 +1578,21 @@ static void tcg_out_setcond(TCGContext *s, int rexw, TCGCond cond,
}
return;

case TCG_COND_GE:
inv = true;
/* fall through */
case TCG_COND_LT:
/* If arg2 is 0, extract the sign bit. */
if (const_arg2 && arg2 == 0) {
tcg_out_mov(s, rexw ? TCG_TYPE_I64 : TCG_TYPE_I32, dest, arg1);
if (inv) {
tcg_out_modrm(s, OPC_GRP3_Ev + rexw, EXT3_NOT, dest);
}
tcg_out_shifti(s, SHIFT_SHR + rexw, dest, rexw ? 63 : 31);
return;
}
break;

default:
break;
}
Expand Down

0 comments on commit e91f015

Please sign in to comment.