From: Richard Henderson Date: Sat, 7 Sep 2024 04:00:10 +0000 (-0700) Subject: tcg/optimize: Fold movcond with true and false values identical X-Git-Tag: v9.2.0-rc0~73^2~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=141125e08cf422e22d40b0114a265c83d888767a;p=thirdparty%2Fqemu.git tcg/optimize: Fold movcond with true and false values identical Fold "x = cond ? y : y" to "x = y". Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- diff --git a/tcg/optimize.c b/tcg/optimize.c index ba16ec27e24..cf311790e05 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1851,6 +1851,11 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op) { int i; + /* If true and false values are the same, eliminate the cmp. */ + if (args_are_copies(op->args[3], op->args[4])) { + return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[3]); + } + /* * Canonicalize the "false" input reg to match the destination reg so * that the tcg backend can implement a "move if true" operation.