qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3 09/30] tcg/loongarch64: Implement tcg_out_mov and tcg_out_


From: WANG Xuerui
Subject: Re: [PATCH v3 09/30] tcg/loongarch64: Implement tcg_out_mov and tcg_out_movi
Date: Thu, 23 Sep 2021 23:38:38 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:94.0) Gecko/20100101 Thunderbird/94.0a1

Hi Richard,

On 9/23/21 02:51, Richard Henderson wrote:
On 9/22/21 11:09 AM, WANG Xuerui wrote:
+    if (sextreg(val, 0, 52) == val) {
+        /*
+         * Fits in 52-bits, upper bits are already properly sign-extended by
+         * cu32i.d.
+         */
+        return;
+    }
+    tcg_out_opc_cu52i_d(s, rd, rd, top);
+}

Oh, future improvement: constants with 52 low zero bits can be loaded with cu52i(rd, zero, val >> 52).

Which means there's a set of interesting constants:

  abc0_0000_0000_0def

    ori    rd, zero, 0xdef
    cu52i    rd, rd, 0xabc

  abcf_ffff_ffff_fdef

    cu52i    rd, zero, 0xabc - 1
    addi.d    rd, rd, 0xdef
I think I'll try to implement this in some kind of follow-up patch, yeah.

Also,

+    tcg_out_opc_lu12i_w(s, rd, upper);
+    if (low != 0) {
+        tcg_out_opc_ori(s, rd, rd, low & 0xfff);
+    }

when upper == 0 and low != 0, we can omit the lu12i.

This optimization can't be blindly implemented though; because cu32i.d only takes one input register, in case upper == low == 0 but higher != 0, we would have no proper input. So in that case something like "move rd, zero" is necessary, and logic is a little bit complicated. I'll include this in v4 though.

r~



reply via email to

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