[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 08/29] tcg/aarch64: Generate TBZ, TBNZ
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH 08/29] tcg/aarch64: Generate TBZ, TBNZ |
Date: |
Fri, 27 Oct 2023 06:44:10 +0200 |
User-agent: |
Mozilla Thunderbird |
On 10/26/23 02:13, Richard Henderson wrote:
+ case TCG_COND_TSTEQ:
+ case TCG_COND_TSTNE:
+ if (b_const && is_power_of_2(b)) {
+ tbit = ctz64(b);
+ need_cmp = false;
+ }
I think another value that can be handled efficiently is 0xffffffff
which becomes a "cbz/cbnz wNN, LABEL" instruction.
This could be interesting if the i386 frontend implemented JE/JNE and
JS/JNS (of sizes smaller than MO_TL) using masks like 0xffffffff and
0x80000000 respectively. Like (for SF):
MemOp size = (s->cc_op - CC_OP_ADDB) & 3;
if (size == MO_TL) {
return (CCPrepare) { .cond = TCG_COND_EQ, .reg = cpu_cc_dst,
.mask = -1 };
} else {
return (CCPrepare) { .cond = TCG_COND_TSTEQ, .reg = cpu_cc_dst,
.imm = (1ull << (8 << size)) - 1,
.mask = -1 };
}
Then on aarch64, JE could become CBZ and JS could become TBNZ.
Unfortunately, the code produced on x86 is not awful but also not too
good; we discussed earlier how TST against 0xffffffff and 0x80000000 can
be computed efficiently using "testl reg, reg", but you don't get to
that point in tcg_out_testi because the other conditions require an S32
constraint. Those constants don't satisfy it. :( So you lose the sign
extension instructions, but you get a somewhat bulky MOV to load the
constant followed by "testl reg, reg_containing_imm".
I guess in principle you could add
TCG_TARGET_{br,mov,set}condi_valid(cond, const) but it's pretty ugly.
Paolo
- [PATCH 11/29] tcg/i386: Move tcg_cond_to_jcc[] into tcg_out_cmp, (continued)
- [PATCH 11/29] tcg/i386: Move tcg_cond_to_jcc[] into tcg_out_cmp, Richard Henderson, 2023/10/25
- [PATCH 09/29] tcg/arm: Support TCG_COND_TST{EQ,NE}, Richard Henderson, 2023/10/25
- [PULL 09/94] target/sparc: Partition cpu features, Richard Henderson, 2023/10/25
- [PULL 10/94] target/sparc: Add decodetree infrastructure, Richard Henderson, 2023/10/25
- [PATCH 01/29] tcg: Introduce TCG_COND_TST{EQ,NE}, Richard Henderson, 2023/10/25
- [PULL 03/94] target/sparc: Avoid helper_raise_exception in helper_st_asi, Richard Henderson, 2023/10/25
- [PULL 07/94] target/sparc: Use CPU_FEATURE_BIT_* for cpu properties, Richard Henderson, 2023/10/25
- [PATCH 03/29] tcg/optimize: Split out do_constant_folding_cond1, Richard Henderson, 2023/10/25
- [PATCH 07/29] tcg/aarch64: Support TCG_COND_TST{EQ,NE}, Richard Henderson, 2023/10/25
- [PATCH 08/29] tcg/aarch64: Generate TBZ, TBNZ, Richard Henderson, 2023/10/25
- Re: [PATCH 08/29] tcg/aarch64: Generate TBZ, TBNZ,
Paolo Bonzini <=
- [PULL 05/94] configs: Enable MTTCG for sparc, sparc64, Richard Henderson, 2023/10/25
- [PATCH 10/29] tcg/i386: Pass x86 condition codes to tcg_out_cmov, Richard Henderson, 2023/10/25
- [PATCH 12/29] tcg/i386: Add rexw argument to tcg_out_testi, Richard Henderson, 2023/10/25
- [PATCH 14/29] tcg/loongarch64: Support TCG_COND_TST{EQ,NE}, Richard Henderson, 2023/10/25
- [PULL 14/94] target/sparc: Move BPr to decodetree, Richard Henderson, 2023/10/25
- [PULL 15/94] target/sparc: Move FBPfcc and FBfcc to decodetree, Richard Henderson, 2023/10/25
- [PULL 18/94] target/sparc: Merge gen_branch_[an] with only caller, Richard Henderson, 2023/10/25
- [PATCH 19/29] tcg/sparc64: Pass TCGCond to tcg_out_cmp, Richard Henderson, 2023/10/25
- [PATCH 15/29] tcg/mips: Support TCG_COND_TST{EQ,NE}, Richard Henderson, 2023/10/25
- [PATCH 16/29] tcg/riscv: Support TCG_COND_TST{EQ,NE}, Richard Henderson, 2023/10/25