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