mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
tcg: Merge INDEX_op_neg_{i32,i64}
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
e126a91c38
commit
6971358747
7 changed files with 18 additions and 40 deletions
|
@ -478,7 +478,7 @@ static uint64_t do_constant_folding_2(TCGOpcode op, uint64_t x, uint64_t y)
|
|||
CASE_OP_32_64_VEC(not):
|
||||
return ~x;
|
||||
|
||||
CASE_OP_32_64(neg):
|
||||
case INDEX_op_neg:
|
||||
return -x;
|
||||
|
||||
case INDEX_op_andc:
|
||||
|
@ -2314,25 +2314,12 @@ static int fold_setcond_zmask(OptContext *ctx, TCGOp *op, bool neg)
|
|||
break;
|
||||
}
|
||||
if (convert) {
|
||||
TCGOpcode neg_opc;
|
||||
|
||||
if (!inv && !neg) {
|
||||
return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]);
|
||||
}
|
||||
|
||||
switch (ctx->type) {
|
||||
case TCG_TYPE_I32:
|
||||
neg_opc = INDEX_op_neg_i32;
|
||||
break;
|
||||
case TCG_TYPE_I64:
|
||||
neg_opc = INDEX_op_neg_i64;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
if (!inv) {
|
||||
op->opc = neg_opc;
|
||||
op->opc = INDEX_op_neg;
|
||||
} else if (neg) {
|
||||
op->opc = INDEX_op_add;
|
||||
op->args[2] = arg_new_constant(ctx, -1);
|
||||
|
@ -2348,7 +2335,7 @@ static int fold_setcond_zmask(OptContext *ctx, TCGOp *op, bool neg)
|
|||
|
||||
static void fold_setcond_tst_pow2(OptContext *ctx, TCGOp *op, bool neg)
|
||||
{
|
||||
TCGOpcode neg_opc, shr_opc;
|
||||
TCGOpcode shr_opc;
|
||||
TCGOpcode uext_opc = 0, sext_opc = 0;
|
||||
TCGCond cond = op->args[3];
|
||||
TCGArg ret, src1, src2;
|
||||
|
@ -2371,7 +2358,6 @@ static void fold_setcond_tst_pow2(OptContext *ctx, TCGOp *op, bool neg)
|
|||
switch (ctx->type) {
|
||||
case TCG_TYPE_I32:
|
||||
shr_opc = INDEX_op_shr_i32;
|
||||
neg_opc = INDEX_op_neg_i32;
|
||||
if (TCG_TARGET_extract_valid(TCG_TYPE_I32, sh, 1)) {
|
||||
uext_opc = INDEX_op_extract_i32;
|
||||
}
|
||||
|
@ -2381,7 +2367,6 @@ static void fold_setcond_tst_pow2(OptContext *ctx, TCGOp *op, bool neg)
|
|||
break;
|
||||
case TCG_TYPE_I64:
|
||||
shr_opc = INDEX_op_shr_i64;
|
||||
neg_opc = INDEX_op_neg_i64;
|
||||
if (TCG_TARGET_extract_valid(TCG_TYPE_I64, sh, 1)) {
|
||||
uext_opc = INDEX_op_extract_i64;
|
||||
}
|
||||
|
@ -2432,7 +2417,7 @@ static void fold_setcond_tst_pow2(OptContext *ctx, TCGOp *op, bool neg)
|
|||
op2->args[1] = ret;
|
||||
op2->args[2] = arg_new_constant(ctx, 1);
|
||||
} else if (neg) {
|
||||
op2 = opt_insert_after(ctx, op, neg_opc, 2);
|
||||
op2 = opt_insert_after(ctx, op, INDEX_op_neg, 2);
|
||||
op2->args[0] = ret;
|
||||
op2->args[1] = ret;
|
||||
}
|
||||
|
@ -2644,11 +2629,8 @@ static bool fold_sub_to_neg(OptContext *ctx, TCGOp *op)
|
|||
|
||||
switch (ctx->type) {
|
||||
case TCG_TYPE_I32:
|
||||
neg_op = INDEX_op_neg_i32;
|
||||
have_neg = true;
|
||||
break;
|
||||
case TCG_TYPE_I64:
|
||||
neg_op = INDEX_op_neg_i64;
|
||||
neg_op = INDEX_op_neg;
|
||||
have_neg = true;
|
||||
break;
|
||||
case TCG_TYPE_V64:
|
||||
|
@ -2998,7 +2980,7 @@ void tcg_optimize(TCGContext *s)
|
|||
case INDEX_op_nand_vec:
|
||||
done = fold_nand(&ctx, op);
|
||||
break;
|
||||
CASE_OP_32_64(neg):
|
||||
case INDEX_op_neg:
|
||||
done = fold_neg(&ctx, op);
|
||||
break;
|
||||
case INDEX_op_nor:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue