tcg/optimize: Use fold_xi_to_x for div

Recognize the identity function for division.

Suggested-by: Luis Pires <luis.pires@eldorado.org.br>
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2021-10-25 11:30:14 -07:00
parent 5b5cf47983
commit 2f9d9a3422

View file

@ -1218,7 +1218,11 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op)
static bool fold_divide(OptContext *ctx, TCGOp *op)
{
return fold_const2(ctx, op);
if (fold_const2(ctx, op) ||
fold_xi_to_x(ctx, op, 1)) {
return true;
}
return false;
}
static bool fold_dup(OptContext *ctx, TCGOp *op)