Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d5c0fbe
latx: simplify AVX floating-point translation
xiezyang Aug 31, 2026
4306df8
latx: reduce copies in AVX moves and shuffles
xiezyang Aug 31, 2026
52b19c9
latx: reduce copies and mask construction in AVX blends
xiezyang Aug 31, 2026
5645089
latx: reduce temporaries in AVX integer translation
xiezyang Aug 31, 2026
3ba8e5e
LATX, opt: Remove redundant copies and inserts in AVX translation
xiezyang Oct 29, 2026
40fff53
LATX, opt: Generate only live flags for AVX scalar comparisons
xiezyang Oct 29, 2026
d16833d
LATX, opt: Generate only live flags for AVX vector tests
xiezyang Oct 29, 2026
e8c3a58
LATX, opt: Branch directly on AVX vector test results
xiezyang Oct 29, 2026
233501c
LATX, opt: Skip FCSR writes for masked fixed VROUNDSD
xiezyang Oct 30, 2026
a315b95
LATX, opt: Avoid scalar-double AVX result copies
xiezyang Oct 30, 2026
cb73354
LATX, opt: Skip redundant FCSR masking in fixed VROUNDSS
xiezyang Oct 30, 2026
38bdbb0
LATX, opt: Reduce XMM VADDSUBPD lane preparation
xiezyang Oct 30, 2026
3663fdb
LATX, opt: Skip VROUNDSS FCSR restore when inexact is already set
xiezyang Oct 30, 2026
358e14e
LATX, opt: Fold large base displacements into load/store offsets
xiezyang Oct 31, 2026
ef2a5a0
LATX, fix: Recover delayed flags without translation-time IR1 data
xiezyang Oct 31, 2026
6d22cb6
LATX, opt: Remove redundant YMM clears after VMOVSS memory loads
xiezyang Nov 2, 2026
d9c2594
LATX, opt: Remove redundant YMM clears after VMOVD XMM writes
xiezyang Nov 2, 2026
c7f005f
LATX, opt: Replicate same-source VPERM2F128 in one instruction
xiezyang Nov 2, 2026
6dd30e2
LATX, opt: Replicate YMM VPERMILPD lanes directly
xiezyang Nov 2, 2026
ea6c0b0
LATX, opt: Replicate XMM VPERMILPD lanes directly
xiezyang Nov 2, 2026
155c405
LATX, opt: Replace the POPCNT bit loop with VPCNT.D
xiezyang Nov 3, 2026
a0002fa
LATX, opt: Remove VINSERTF128 copies when dest is src1
xiezyang Nov 3, 2026
3ec116d
LATX, opt: Skip unused src1 upper-half clears in VINSERTF128
xiezyang Nov 3, 2026
49e6b17
LATX, fix: Avoid oversized VBROADCASTSD memory reads
xiezyang Nov 3, 2026
5741440
LATX, opt: Avoid VCVTSS2SD result copies when dest is src1
xiezyang Nov 3, 2026
0fdd36e
LATX, opt: Remove redundant VMOVSD register copies
xiezyang Nov 3, 2026
18e2536
LATX, opt: Interleave YMM VSHUFPD lanes directly
xiezyang Nov 3, 2026
d10a5b7
LATX, opt: Avoid VCVTSI2SD result copies when dest is src1
xiezyang Nov 4, 2026
dbd2d3f
LATX, opt: Skip unused src1 upper-half clears in VINSERTI128
xiezyang Nov 9, 2026
eb2f63e
LATX, fix: Keep memory SETA outside scalar compare fusion
xiezyang Nov 11, 2026
a47b884
LATX, fix: Preserve comparison flags before faults after VUCOMISD/SETA
xiezyang Nov 11, 2026
b2d37b7
LATX, opt: Share UCOMISD and VUCOMISD register SETA fusion
xiezyang Nov 11, 2026
50a1bc4
LATX, opt: Write non-aliasing VCMPSD results directly
xiezyang Nov 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions accel/tcg/translate-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ int encode_search(TranslationBlock *tb, uint8_t *block)
#ifdef CONFIG_LATX_OPT_PUSH_POP
extern void ir2_opt_push_pop_fix(TranslationBlock *tb, CPUState *cpu, int i);
#endif
extern void opt_instptn_fix(CPUState *cpu, TranslationBlock *tb, int i);

/* The cpu state corresponding to 'searched_pc' is restored.
* When reset_icount is true, current TB will be interrupted and
Expand Down Expand Up @@ -486,9 +485,6 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
ir2_opt_push_pop_fix(tb, cpu, (searched_pc - (uintptr_t)tb->tc.ptr) / 4);
}
#endif
#ifdef CONFIG_LATX_INSTS_PATTERN
opt_instptn_fix(cpu, tb, i);
#endif
#ifdef CONFIG_PROFILER
qatomic_set(&prof->restore_time,
prof->restore_time + profile_getclock() - ti);
Expand Down
5 changes: 5 additions & 0 deletions target/i386/latx/include/insts-pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,9 @@ bool insts_pattern_scan_jcc_end(TranslationBlock *tb, IR1_INST *ir1, int index,

bool try_translate_instptn(IR1_INST *pir1);

#ifdef CONFIG_LATX_INSTS_PATTERN
unsigned instptn_flags_recovery(IR1_INST *pir1);
void opt_instptn_fix(CPUArchState *env, unsigned recovery);
#endif

#endif
3 changes: 0 additions & 3 deletions target/i386/latx/include/ir2.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,5 @@ bool la_ir2_opcode_is_load(IR2_OPCODE opcode);
void tr_ir2_optimize(TranslationBlock *tb);

void ir2_opt_push_pop_fix(TranslationBlock *tb, CPUState *cpu, int i);
#ifdef CONFIG_LATX_INSTS_PATTERN
void opt_instptn_fix(CPUState *cpu, TranslationBlock *tb, int index);
#endif
void la_append_ir2_jmp_far(ADDR jmp_offset);
#endif
29 changes: 29 additions & 0 deletions target/i386/latx/include/latx-unwind.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-FileCopyrightText: 2021-2026 LAT Project Authors
*
* SPDX-License-Identifier: GPL-2.0-only
*/

#ifndef LATX_UNWIND_H
#define LATX_UNWIND_H

/* Layout of the second per-instruction search-table word, also on i386. */
#define LATX_UNWIND_CC_OP_MASK 0xff
#define LATX_UNWIND_INSTPTN_SHIFT 8
#define LATX_UNWIND_INSTPTN_MASK 0xff
#define LATX_UNWIND_YMMH_SHIFT 16

/* Delayed integer flags use the saved host a0/a1, never temporary IR1. */
enum {
INSTPTN_FLAGS_NONE,
INSTPTN_FLAGS_CMP,
INSTPTN_FLAGS_TEST,
INSTPTN_FLAGS_BT,
};

#define INSTPTN_FLAGS_OP_MASK 3
#define INSTPTN_FLAGS_SIZE_SHIFT 2
#define INSTPTN_FLAGS_SIZE_MASK 3
#define INSTPTN_FLAGS_SAME_REG (1 << 4)

#endif
2 changes: 2 additions & 0 deletions target/i386/latx/include/translate.h
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,8 @@ TRANS_FUNC_DEF(vpshufb_lsx);
TRANS_FUNC_DEF(vpsubx);
TRANS_FUNC_DEF(vptest);
TRANS_FUNC_DEF(vptest_lsx);
void generate_avx_test_flags(IR1_INST *, IR2_OPND, IR2_OPND, IR2_OPND,
uint8_t);
TRANS_FUNC_DEF(vpunpckhxx);
TRANS_FUNC_DEF(vpunpckhxx_lsx);
TRANS_FUNC_DEF(vpunpcklxx);
Expand Down
3 changes: 3 additions & 0 deletions target/i386/latx/optimization/flag-reduction.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ static const IR1_EFLAG_USEDEF ir1_opcode_eflag_usedef[] = {
FLAG_DEFINE(VCOMISS, __NONE, __ALL_EFLAGS, __NONE),
FLAG_DEFINE(VUCOMISD, __NONE, __ALL_EFLAGS, __NONE),
FLAG_DEFINE(VUCOMISS, __NONE, __ALL_EFLAGS, __NONE),
FLAG_DEFINE(VPTEST, __NONE, __ALL_EFLAGS, __NONE),
FLAG_DEFINE(VTESTPS, __NONE, __ALL_EFLAGS, __NONE),
FLAG_DEFINE(VTESTPD, __NONE, __ALL_EFLAGS, __NONE),
FLAG_DEFINE(IRET, __NONE, __INVALID, __NONE),

/* Jcc */
Expand Down
43 changes: 43 additions & 0 deletions target/i386/latx/optimization/insts-pattern.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ static inline bool ir1_can_pattern(IR1_INST *pir1)
case WRAP(CDQ):
case WRAP(TEST):
case WRAP(UCOMISD):
#ifdef CONFIG_LATX_AVX_OPT
case WRAP(VUCOMISD):
#endif
#ifdef CONFIG_LATX_SMC_OPT
case WRAP(MOVAPS):
case WRAP(MOVDQA):
Expand Down Expand Up @@ -101,6 +104,9 @@ static inline bool ir1_is_pattern_head(IR1_INST *pir1)
case WRAP(CDQ):
case WRAP(TEST):
case WRAP(UCOMISD):
#ifdef CONFIG_LATX_AVX_OPT
case WRAP(VUCOMISD):
#endif
#ifdef CONFIG_LATX_SMC_OPT
case WRAP(MOVAPS):
case WRAP(MOVDQA):
Expand Down Expand Up @@ -333,12 +339,23 @@ static int inst_pattern(TranslationBlock *tb,
return 0;
}
case WRAP(UCOMISD):
#ifdef CONFIG_LATX_AVX_OPT
case WRAP(VUCOMISD):
#endif
SCAN_CHECK(scan, 0);
instptn_check_ucomisd_seta_0();

ir1 = SCAN_IR1(tb, scan, 0);
if (ir1_addr_next(pir1) != ir1_addr(ir1)) {
return 0;
}
switch (ir1_opcode(ir1)) {
case WRAP(SETA):
/* A fused store has no separate SETA fault boundary. */
if (!ir1_opnd_is_gpr(ir1_get_opnd(ir1, 0))) {
ir1_set_eflag_def(pir1, 0x3f);
return 0;
}
pir1->instptn.opc = INSTPTN_OPC_UCOMISD_SETA;
pir1->instptn.next = ir1;
ir1->instptn.opc = INSTPTN_OPC_NOP;
Expand Down Expand Up @@ -443,6 +460,32 @@ bool insts_pattern_scan_jcc_end(TranslationBlock *tb, IR1_INST *pir1, int pir1_i
IR1_OPND *opnd0 = NULL;
IR1_OPND *opnd1 = NULL;
switch (ir1_opcode(pir1)) {
#ifdef CONFIG_LATX_AVX_OPT
case WRAP(VPTEST):
case WRAP(VTESTPS):
case WRAP(VTESTPD):
SCAN_CHECK(scan, 0);
ir1_jcc = SCAN_IR1(tb, scan, 0);
if (!option_enable_lasx || pir1_index + 1 != SCAN_IDX(scan, 0)) {
return false;
}
switch (ir1_opcode(ir1_jcc)) {
case WRAP(JE):
case WRAP(JNE):
case WRAP(JB):
case WRAP(JAE):
case WRAP(JBE):
case WRAP(JA):
instptn_check_test_jcc_0();
pir1->instptn.opc = INSTPTN_OPC_TEST_JCC;
pir1->instptn.next = ir1_jcc;
ir1_jcc->instptn.opc = INSTPTN_OPC_NOP;
break;
default:
break;
}
return false;
#endif
case WRAP(CMP):
SCAN_CHECK(scan, 0);
ir1_jcc = SCAN_IR1(tb, scan, 0);
Expand Down
18 changes: 18 additions & 0 deletions target/i386/latx/translator/mem-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,24 @@ static IR2_OPND convert_mem_helper(IR1_OPND *opnd1, IR2_OPND *arg_dest_op,
if (host_off) {
if (si12_overflow(offset)) {
*host_off = 0;
#ifdef TARGET_X86_64
bool split_offset = CODEIS64 && ir1_addr_size(pir1) == 64 &&
has_base && !has_index && !has_seg &&
ir1_opnd_size(opnd1) != 80;
#ifdef CONFIG_LATX_IMM_REG
split_offset = split_offset &&
(!option_imm_reg || !option_imm_complex);
#endif
if (split_offset) {
longx low = sextract64(offset, 0, 12);
longx high = offset - low;
if (low && high == (int32_t)high) {
/* Keep the low displacement in the load/store itself. */
*host_off = low;
offset = high;
}
}
#endif
} else {
#ifdef CONFIG_LATX_IMM_REG
cache_skip = true;
Expand Down
Loading
Loading