]> git.proxmox.com Git - mirror_qemu.git/commitdiff
tcg/optimize: Fold movcond 0/1 into setcond
authorRichard Henderson <rth@twiddle.net>
Mon, 24 Oct 2016 03:44:32 +0000 (20:44 -0700)
committerRichard Henderson <rth@twiddle.net>
Tue, 10 Jan 2017 16:06:10 +0000 (08:06 -0800)
Signed-off-by: Richard Henderson <rth@twiddle.net>
tcg/optimize.c

index f41ed2cfc1165ac18298c71c66bb65f6914ebed7..9e26bb7e4ed9d025dbaf21ce93dc8eeb6a5bf1a0 100644 (file)
@@ -1105,6 +1105,21 @@ void tcg_optimize(TCGContext *s)
                 tcg_opt_gen_mov(s, op, args, args[0], args[4-tmp]);
                 break;
             }
+            if (temp_is_const(args[3]) && temp_is_const(args[4])) {
+                tcg_target_ulong tv = temps[args[3]].val;
+                tcg_target_ulong fv = temps[args[4]].val;
+                TCGCond cond = args[5];
+                if (fv == 1 && tv == 0) {
+                    cond = tcg_invert_cond(cond);
+                } else if (!(tv == 1 && fv == 0)) {
+                    goto do_default;
+                }
+                args[3] = cond;
+                op->opc = opc = (opc == INDEX_op_movcond_i32
+                                 ? INDEX_op_setcond_i32
+                                 : INDEX_op_setcond_i64);
+                nb_iargs = 2;
+            }
             goto do_default;
 
         case INDEX_op_add2_i32: