tcg/optimize: Add more identity simplifications
Recognize 0 operand to andc, and -1 operands to and, orc, eqv. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
parent
e64e958e20
commit
464a1441c1
|
@ -716,7 +716,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Simplify expression for "op r, a, 0 => mov r, a" cases */
|
/* Simplify expression for "op r, a, const => mov r, a" cases */
|
||||||
switch (op) {
|
switch (op) {
|
||||||
CASE_OP_32_64(add):
|
CASE_OP_32_64(add):
|
||||||
CASE_OP_32_64(sub):
|
CASE_OP_32_64(sub):
|
||||||
|
@ -727,12 +727,23 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
||||||
CASE_OP_32_64(rotr):
|
CASE_OP_32_64(rotr):
|
||||||
CASE_OP_32_64(or):
|
CASE_OP_32_64(or):
|
||||||
CASE_OP_32_64(xor):
|
CASE_OP_32_64(xor):
|
||||||
if (temps[args[1]].state == TCG_TEMP_CONST) {
|
CASE_OP_32_64(andc):
|
||||||
/* Proceed with possible constant folding. */
|
if (temps[args[1]].state != TCG_TEMP_CONST
|
||||||
break;
|
&& temps[args[2]].state == TCG_TEMP_CONST
|
||||||
}
|
|
||||||
if (temps[args[2]].state == TCG_TEMP_CONST
|
|
||||||
&& temps[args[2]].val == 0) {
|
&& temps[args[2]].val == 0) {
|
||||||
|
goto do_mov3;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
CASE_OP_32_64(and):
|
||||||
|
CASE_OP_32_64(orc):
|
||||||
|
CASE_OP_32_64(eqv):
|
||||||
|
if (temps[args[1]].state != TCG_TEMP_CONST
|
||||||
|
&& temps[args[2]].state == TCG_TEMP_CONST
|
||||||
|
&& temps[args[2]].val == -1) {
|
||||||
|
goto do_mov3;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
do_mov3:
|
||||||
if (temps_are_copies(args[0], args[1])) {
|
if (temps_are_copies(args[0], args[1])) {
|
||||||
s->gen_opc_buf[op_index] = INDEX_op_nop;
|
s->gen_opc_buf[op_index] = INDEX_op_nop;
|
||||||
} else {
|
} else {
|
||||||
|
@ -742,8 +753,6 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
|
||||||
}
|
}
|
||||||
args += 3;
|
args += 3;
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue