mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
tcg/optimize: swap brcond/setcond arguments when possible
brcond and setcond ops are not commutative, but it's easy to compute the new condition after swapping the arguments. Try to always put the constant argument in second position like for commutative ops, to help backends to generate better code. Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
@@ -318,6 +318,24 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
||||
args[2] = tmp;
|
||||
}
|
||||
break;
|
||||
CASE_OP_32_64(brcond):
|
||||
if (temps[args[0]].state == TCG_TEMP_CONST
|
||||
&& temps[args[1]].state != TCG_TEMP_CONST) {
|
||||
tmp = args[0];
|
||||
args[0] = args[1];
|
||||
args[1] = tmp;
|
||||
args[2] = tcg_swap_cond(args[2]);
|
||||
}
|
||||
break;
|
||||
CASE_OP_32_64(setcond):
|
||||
if (temps[args[1]].state == TCG_TEMP_CONST
|
||||
&& temps[args[2]].state != TCG_TEMP_CONST) {
|
||||
tmp = args[1];
|
||||
args[1] = args[2];
|
||||
args[2] = tmp;
|
||||
args[3] = tcg_swap_cond(args[3]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user