mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
tcg/optimize: Build and use z_bits and o_bits in fold_extract2
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
+25
-13
@@ -1099,6 +1099,12 @@ static bool fold_masks_zos(OptContext *ctx, TCGOp *op,
|
||||
return fold_masks_zosa(ctx, op, z_mask, o_mask, s_mask, -1);
|
||||
}
|
||||
|
||||
static bool fold_masks_zo(OptContext *ctx, TCGOp *op,
|
||||
uint64_t z_mask, uint64_t o_mask)
|
||||
{
|
||||
return fold_masks_zosa(ctx, op, z_mask, o_mask, 0, -1);
|
||||
}
|
||||
|
||||
static bool fold_masks_zs(OptContext *ctx, TCGOp *op,
|
||||
uint64_t z_mask, uint64_t s_mask)
|
||||
{
|
||||
@@ -1982,21 +1988,27 @@ static bool fold_extract(OptContext *ctx, TCGOp *op)
|
||||
|
||||
static bool fold_extract2(OptContext *ctx, TCGOp *op)
|
||||
{
|
||||
if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) {
|
||||
uint64_t v1 = arg_const_val(op->args[1]);
|
||||
uint64_t v2 = arg_const_val(op->args[2]);
|
||||
int shr = op->args[3];
|
||||
TempOptInfo *t1 = arg_info(op->args[1]);
|
||||
TempOptInfo *t2 = arg_info(op->args[2]);
|
||||
uint64_t z1 = t1->z_mask;
|
||||
uint64_t z2 = t2->z_mask;
|
||||
uint64_t o1 = t1->o_mask;
|
||||
uint64_t o2 = t2->o_mask;
|
||||
int shr = op->args[3];
|
||||
|
||||
if (ctx->type == TCG_TYPE_I32) {
|
||||
v1 = (uint32_t)v1 >> shr;
|
||||
v2 = (uint64_t)((int32_t)v2 << (32 - shr));
|
||||
} else {
|
||||
v1 >>= shr;
|
||||
v2 <<= 64 - shr;
|
||||
}
|
||||
return tcg_opt_gen_movi(ctx, op, op->args[0], v1 | v2);
|
||||
if (ctx->type == TCG_TYPE_I32) {
|
||||
z1 = (uint32_t)z1 >> shr;
|
||||
o1 = (uint32_t)o1 >> shr;
|
||||
z2 = (uint64_t)((int32_t)z2 << (32 - shr));
|
||||
o2 = (uint64_t)((int32_t)o2 << (32 - shr));
|
||||
} else {
|
||||
z1 >>= shr;
|
||||
o1 >>= shr;
|
||||
z2 <<= 64 - shr;
|
||||
o2 <<= 64 - shr;
|
||||
}
|
||||
return finish_folding(ctx, op);
|
||||
|
||||
return fold_masks_zo(ctx, op, z1 | z2, o1 | o2);
|
||||
}
|
||||
|
||||
static bool fold_exts(OptContext *ctx, TCGOp *op)
|
||||
|
||||
Reference in New Issue
Block a user