mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-30 13:53:54 -06:00
tcg/optimize: Use fold_masks_zs, fold_masks_s in fold_shift
Avoid the use of the OptContext slots. Find TempOptInfo once. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
baff507e50
commit
4e9ce6a2ec
1 changed files with 14 additions and 13 deletions
|
@ -2531,6 +2531,7 @@ static bool fold_sextract(OptContext *ctx, TCGOp *op)
|
||||||
static bool fold_shift(OptContext *ctx, TCGOp *op)
|
static bool fold_shift(OptContext *ctx, TCGOp *op)
|
||||||
{
|
{
|
||||||
uint64_t s_mask, z_mask, sign;
|
uint64_t s_mask, z_mask, sign;
|
||||||
|
TempOptInfo *t1, *t2;
|
||||||
|
|
||||||
if (fold_const2(ctx, op) ||
|
if (fold_const2(ctx, op) ||
|
||||||
fold_ix_to_i(ctx, op, 0) ||
|
fold_ix_to_i(ctx, op, 0) ||
|
||||||
|
@ -2538,17 +2539,18 @@ static bool fold_shift(OptContext *ctx, TCGOp *op)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_mask = arg_info(op->args[1])->s_mask;
|
t1 = arg_info(op->args[1]);
|
||||||
z_mask = arg_info(op->args[1])->z_mask;
|
t2 = arg_info(op->args[2]);
|
||||||
|
s_mask = t1->s_mask;
|
||||||
|
z_mask = t1->z_mask;
|
||||||
|
|
||||||
if (arg_is_const(op->args[2])) {
|
if (ti_is_const(t2)) {
|
||||||
int sh = arg_info(op->args[2])->val;
|
int sh = ti_const_val(t2);
|
||||||
|
|
||||||
ctx->z_mask = do_constant_folding(op->opc, ctx->type, z_mask, sh);
|
|
||||||
|
|
||||||
|
z_mask = do_constant_folding(op->opc, ctx->type, z_mask, sh);
|
||||||
s_mask = do_constant_folding(op->opc, ctx->type, s_mask, sh);
|
s_mask = do_constant_folding(op->opc, ctx->type, s_mask, sh);
|
||||||
|
|
||||||
return fold_masks(ctx, op);
|
return fold_masks_zs(ctx, op, z_mask, s_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (op->opc) {
|
switch (op->opc) {
|
||||||
|
@ -2557,23 +2559,22 @@ static bool fold_shift(OptContext *ctx, TCGOp *op)
|
||||||
* Arithmetic right shift will not reduce the number of
|
* Arithmetic right shift will not reduce the number of
|
||||||
* input sign repetitions.
|
* input sign repetitions.
|
||||||
*/
|
*/
|
||||||
ctx->s_mask = s_mask;
|
return fold_masks_s(ctx, op, s_mask);
|
||||||
break;
|
|
||||||
CASE_OP_32_64(shr):
|
CASE_OP_32_64(shr):
|
||||||
/*
|
/*
|
||||||
* If the sign bit is known zero, then logical right shift
|
* If the sign bit is known zero, then logical right shift
|
||||||
* will not reduced the number of input sign repetitions.
|
* will not reduce the number of input sign repetitions.
|
||||||
*/
|
*/
|
||||||
sign = (s_mask & -s_mask) >> 1;
|
sign = -s_mask;
|
||||||
if (sign && !(z_mask & sign)) {
|
if (sign && !(z_mask & sign)) {
|
||||||
ctx->s_mask = s_mask;
|
return fold_masks_s(ctx, op, s_mask);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return finish_folding(ctx, op);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool fold_sub_to_neg(OptContext *ctx, TCGOp *op)
|
static bool fold_sub_to_neg(OptContext *ctx, TCGOp *op)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue