[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 27/27] tcg/s390x: Avoid the constant pool in tcg_out_movi
From: |
Richard Henderson |
Subject: |
[PATCH v4 27/27] tcg/s390x: Avoid the constant pool in tcg_out_movi |
Date: |
Thu, 8 Dec 2022 20:05:30 -0600 |
Load constants in no more than two insns, which turns
out to be faster than using the constant pool.
Suggested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/s390x/tcg-target.c.inc | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc
index b72c43e4aa..2b38fd991d 100644
--- a/tcg/s390x/tcg-target.c.inc
+++ b/tcg/s390x/tcg-target.c.inc
@@ -877,6 +877,9 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg
dst, TCGReg src)
static const S390Opcode li_insns[4] = {
RI_LLILL, RI_LLILH, RI_LLIHL, RI_LLIHH
};
+static const S390Opcode oi_insns[4] = {
+ RI_OILL, RI_OILH, RI_OIHL, RI_OIHH
+};
static const S390Opcode lif_insns[2] = {
RIL_LLILF, RIL_LLIHF,
};
@@ -928,9 +931,20 @@ static void tcg_out_movi(TCGContext *s, TCGType type,
return;
}
- /* Otherwise, stuff it in the constant pool. */
- tcg_out_insn(s, RIL, LGRL, ret, 0);
- new_pool_label(s, sval, R_390_PC32DBL, s->code_ptr - 2, 2);
+ /* Otherwise, load it by parts. */
+ i = is_const_p16((uint32_t)uval);
+ if (i >= 0) {
+ tcg_out_insn_RI(s, li_insns[i], ret, uval >> (i * 16));
+ } else {
+ tcg_out_insn(s, RIL, LLILF, ret, uval);
+ }
+ uval >>= 32;
+ i = is_const_p16(uval);
+ if (i >= 0) {
+ tcg_out_insn_RI(s, oi_insns[i + 2], ret, uval >> (i * 16));
+ } else {
+ tcg_out_insn(s, RIL, OIHF, ret, uval);
+ }
}
/* Emit a load/store type instruction. Inputs are:
@@ -1160,9 +1174,6 @@ static void tgen_andi(TCGContext *s, TCGType type, TCGReg
dest, uint64_t val)
static void tgen_ori(TCGContext *s, TCGReg dest, uint64_t val)
{
- static const S390Opcode oi_insns[4] = {
- RI_OILL, RI_OILH, RI_OIHL, RI_OIHH
- };
static const S390Opcode oif_insns[2] = {
RIL_OILF, RIL_OIHF
};
--
2.34.1
- [PATCH v4 14/27] tcg/s390x: Support MIE2 multiply single instructions, (continued)
- [PATCH v4 14/27] tcg/s390x: Support MIE2 multiply single instructions, Richard Henderson, 2022/12/08
- [PATCH v4 20/27] tcg/s390x: Create tgen_cmp2 to simplify movcond, Richard Henderson, 2022/12/08
- [PATCH v4 21/27] tcg/s390x: Generalize movcond implementation, Richard Henderson, 2022/12/08
- [PATCH v4 22/27] tcg/s390x: Support SELGR instruction in movcond, Richard Henderson, 2022/12/08
- [PATCH v4 23/27] tcg/s390x: Use tgen_movcond_int in tgen_clz, Richard Henderson, 2022/12/08
- [PATCH v4 24/27] tcg/s390x: Implement ctpop operation, Richard Henderson, 2022/12/08
- [PATCH v4 25/27] tcg/s390x: Tighten constraints for 64-bit compare, Richard Henderson, 2022/12/08
- [PATCH v4 27/27] tcg/s390x: Avoid the constant pool in tcg_out_movi,
Richard Henderson <=
- [PATCH v4 26/27] tcg/s390x: Cleanup tcg_out_movi, Richard Henderson, 2022/12/08
- Re: [PATCH v4 00/27] tcg/s390x: misc patches, Ilya Leoshkevich, 2022/12/13