diff options
| author | Richard Henderson | 2017-01-17 21:02:08 +0100 |
|---|---|---|
| committer | Richard Henderson | 2017-01-17 21:02:08 +0100 |
| commit | 39f099ec9d6d420b6fe6f7f4f8ed80ae29c65ff2 (patch) | |
| tree | ec515d8cf3d0f04629dda46f269cad2bc0fa2069 | |
| parent | Revert "tcg/i386: Rely on undefined/undocumented behaviour of BSF/BSR" (diff) | |
| download | qemu-39f099ec9d6d420b6fe6f7f4f8ed80ae29c65ff2.tar.gz qemu-39f099ec9d6d420b6fe6f7f4f8ed80ae29c65ff2.tar.xz qemu-39f099ec9d6d420b6fe6f7f4f8ed80ae29c65ff2.zip | |
tcg/i386: Always use TZCNT when available
I think this is cleaner than sometimes using BSF.
Signed-off-by: Richard Henderson <rth@twiddle.net>
| -rw-r--r-- | tcg/i386/tcg-target.inc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 6489b73862..5918008296 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -1143,10 +1143,14 @@ static void tcg_out_movcond64(TCGContext *s, TCGCond cond, TCGReg dest, static void tcg_out_ctz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, TCGArg arg2, bool const_a2) { - if (const_a2) { - tcg_debug_assert(have_bmi1); - tcg_debug_assert(arg2 == (rexw ? 64 : 32)); + if (have_bmi1) { tcg_out_modrm(s, OPC_TZCNT + rexw, dest, arg1); + if (const_a2) { + tcg_debug_assert(arg2 == (rexw ? 64 : 32)); + } else { + tcg_debug_assert(dest != arg2); + tcg_out_cmov(s, TCG_COND_LTU, rexw, dest, arg2); + } } else { tcg_debug_assert(dest != arg2); tcg_out_modrm(s, OPC_BSF + rexw, dest, arg1); |
