diff options
| author | Richard Henderson <richard.henderson@linaro.org> | 2023-11-15 11:18:55 -0800 |
|---|---|---|
| committer | Richard Henderson <richard.henderson@linaro.org> | 2025-04-28 13:40:15 -0700 |
| commit | 899281c8f589cce55951e13307661a7253eb4909 (patch) | |
| tree | 4b958d74a539f15e4a65af330b19b1cbde917188 /tcg/optimize.c | |
| parent | c3b920b3d6a685484904d3060f3eb69401051bf0 (diff) | |
| download | focaccia-qemu-899281c8f589cce55951e13307661a7253eb4909.tar.gz focaccia-qemu-899281c8f589cce55951e13307661a7253eb4909.zip | |
tcg/optimize: Fold andc with immediate to and
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'tcg/optimize.c')
| -rw-r--r-- | tcg/optimize.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tcg/optimize.c b/tcg/optimize.c index 20cde598fb..1f6fdee734 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1343,6 +1343,25 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) t2 = arg_info(op->args[2]); z_mask = t1->z_mask; + if (ti_is_const(t2)) { + /* Fold andc r,x,i to and r,x,~i. */ + switch (ctx->type) { + case TCG_TYPE_I32: + case TCG_TYPE_I64: + op->opc = INDEX_op_and; + break; + case TCG_TYPE_V64: + case TCG_TYPE_V128: + case TCG_TYPE_V256: + op->opc = INDEX_op_and_vec; + break; + default: + g_assert_not_reached(); + } + op->args[2] = arg_new_constant(ctx, ~ti_const_val(t2)); + return fold_and(ctx, op); + } + /* * Known-zeros does not imply known-ones. Therefore unless * arg2 is constant, we can't infer anything from it. |