On 11/5/2026 5:46 AM, Anton Johansson wrote:
A packet containing HLX instructions currently defers all stores to the end of the packet, this breaks scalar :mem_noshuf ordering. Only reorder HLX stores. Fixes: a6fae6da070d66b9 ("target/hexagon: translate packets with HLX instructions") Signed-off-by: Anton Johansson <[email protected]> --- target/hexagon/translate.c | 7 ++++--- tests/tcg/hexagon/hlx_mem.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index 8ab28d40d3..f9d4c3fb66 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -1525,8 +1525,10 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx) for (int pass = 0; pass < 3; pass++) { for (i = 0; i < ctx->pkt.num_insns; i++) { Insn *insn = &ctx->pkt.insn[i]; + bool hlx = GET_ATTRIB(insn->opcode, A_HLX); bool tmp = GET_ATTRIB(insn->opcode, A_HLX_TMP); - bool store = !tmp && GET_ATTRIB(insn->opcode, A_STORE); + bool store = !tmp && hlx && + GET_ATTRIB(insn->opcode, A_STORE); if (pass != (tmp ? 0 : store ? 2 : 1)) { continue; } @@ -1534,8 +1536,7 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx) if (insn->hlx_new_zero) { gen_hlx_new_zero(insn); } - if (GET_ATTRIB(insn->opcode, A_HLX) && - trace_event_get_state_backends( + if (hlx && trace_event_get_state_backends( TRACE_HEXAGON_HLX_OP)) { gen_helper_hlx_trace_op(tcg_env, tcg_constant_i32(insn->opcode)); diff --git a/tests/tcg/hexagon/hlx_mem.c b/tests/tcg/hexagon/hlx_mem.c index 643b499fd9..f5af95115a 100644 --- a/tests/tcg/hexagon/hlx_mem.c +++ b/tests/tcg/hexagon/hlx_mem.c @@ -229,6 +229,25 @@ static void test_store_fault(void) check_h("LX_S16b_new (fault)", buf_out, expected, HLX_HALF_ELEMS); }+static void test_preserve_scalar_noshuf(void)+{ + uint32_t ret = 0; + uint32_t ptr = 0; + uint32_t val = 0x1234; + asm volatile("{\n" + ".word 0xe5007822\n" + " memw(%1) = %2\n" + " %0 = memw(%1)\n" + "}:mem_noshuf\n" + : "=r"(ret) + : "r"(&ptr), "r"(val)
IMO it's a nice-to-have to use named-parameter substitution for inline asm instead of enumerated parameters.
If you decide to make that change: great. Regardless, Reviewed-by: Brian Cain <[email protected]>
+ : "memory"); + if (ret != val) { + printf("FAIL broken scalar :mem_noshuf ordering\n"); + err++; + } +} + int main(void) { init_vtcm(); @@ -253,6 +272,9 @@ int main(void) /* Store in a faulting packet */ test_store_fault();+ /* Make sure HLX packets preserve scalar :mem_noshuf ordering */+ test_preserve_scalar_noshuf(); + puts(err ? "FAIL" : "PASS"); return err; }
