qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH] tcg: allow a target to request canonicalization of SUBI


From: Richard Henderson
Subject: Re: [RFC PATCH] tcg: allow a target to request canonicalization of SUBI to ADDI
Date: Wed, 25 Oct 2023 13:42:18 -0700
User-agent: Mozilla Thunderbird

On 10/25/23 11:59, Paolo Bonzini wrote:
On x86, this is more efficient because it enables generation of
more LEA instructions.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
  include/tcg/tcg.h     |  4 ++++
  tcg/i386/tcg-target.h |  2 ++
  tcg/tcg-op.c          | 20 ++++++++++++++++----
  3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index a9282cdcc60..48e5aeef173 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -109,6 +109,10 @@ typedef uint64_t TCGRegSet;
  #define TCG_TARGET_HAS_sub2_i32         1
  #endif
+#ifndef TCG_TARGET_PREFERS_addi
+#define TCG_TARGET_PREFERS_addi         0
+#endif

I would rather do this unconditionally.

Many of the tcg backends do this manually, e.g. s390x:

    case INDEX_op_sub_i64:
        a0 = args[0], a1 = args[1], a2 = args[2];
        if (const_args[2]) {
            a2 = -a2;
            goto do_addi_64;
        } else {
            tcg_out_insn(s, RRFa, SGRK, a0, a1, a2);
        }
        break;

While we could do something similar for i386, it would be better to not require such hoops in each backend.

We would also want to perform this transformation in optimize.c.


r~




reply via email to

[Prev in Thread] Current Thread [Next in Thread]