]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
tcg/i386: Always use TZCNT when available
authorRichard Henderson <rth@twiddle.net>
Tue, 17 Jan 2017 20:02:08 +0000 (12:02 -0800)
committerRichard Henderson <rth@twiddle.net>
Tue, 17 Jan 2017 20:02:08 +0000 (12:02 -0800)
I think this is cleaner than sometimes using BSF.

Signed-off-by: Richard Henderson <rth@twiddle.net>
tcg/i386/tcg-target.inc.c

index 6489b7386221ff02745afc9258cdce8c61828195..591800829633bd84c661a10f5c9788977955851b 100644 (file)
@@ -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);