From: Richard Henderson <[email protected]> In order to ease next commit review, check arg2 constness in the inner loop.
Signed-off-by: Richard Henderson <[email protected]> [PMD: Split of following commit] Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- tcg/optimize.c | 68 +++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index b1abec69a5d..ef5eb2cf175 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2173,45 +2173,45 @@ static bool fold_multiply2(OptContext *ctx, TCGOp *op) { swap_commutative(op->args[0], &op->args[2], &op->args[3]); - if (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) { - uint64_t a = arg_const_val(op->args[2]); + if (arg_is_const(op->args[3])) { uint64_t b = arg_const_val(op->args[3]); - uint64_t h, l; - TCGArg rl, rh; + TCGArg rl = op->args[0]; + TCGArg rh = op->args[1]; TCGOp *op2; - switch (op->opc) { - case INDEX_op_mulu2: - if (ctx->type == TCG_TYPE_I32) { - l = (uint64_t)(uint32_t)a * (uint32_t)b; - h = (int32_t)(l >> 32); - l = (int32_t)l; - } else { - mulu64(&l, &h, a, b); + if (arg_is_const(op->args[2])) { + uint64_t a = arg_const_val(op->args[2]); + uint64_t h, l; + + switch (op->opc) { + case INDEX_op_mulu2: + if (ctx->type == TCG_TYPE_I32) { + l = (uint64_t)(uint32_t)a * (uint32_t)b; + h = (int32_t)(l >> 32); + l = (int32_t)l; + } else { + mulu64(&l, &h, a, b); + } + break; + case INDEX_op_muls2: + if (ctx->type == TCG_TYPE_I32) { + l = (int64_t)(int32_t)a * (int32_t)b; + h = l >> 32; + l = (int32_t)l; + } else { + muls64(&l, &h, a, b); + } + break; + default: + g_assert_not_reached(); } - break; - case INDEX_op_muls2: - if (ctx->type == TCG_TYPE_I32) { - l = (int64_t)(int32_t)a * (int32_t)b; - h = l >> 32; - l = (int32_t)l; - } else { - muls64(&l, &h, a, b); - } - break; - default: - g_assert_not_reached(); + + /* The proper opcode is supplied by tcg_opt_gen_mov. */ + op2 = opt_insert_before(ctx, op, 0, 2); + tcg_opt_gen_movi(ctx, op, rl, l); + tcg_opt_gen_movi(ctx, op2, rh, h); + return true; } - - rl = op->args[0]; - rh = op->args[1]; - - /* The proper opcode is supplied by tcg_opt_gen_mov. */ - op2 = opt_insert_before(ctx, op, 0, 2); - - tcg_opt_gen_movi(ctx, op, rl, l); - tcg_opt_gen_movi(ctx, op2, rh, h); - return true; } return finish_folding(ctx, op); } -- 2.53.0
