From: Brian Cain <brian.cain@oss.qualcomm.com>
To: qemu-devel@nongnu.org
Cc: Brian Cain <brian.cain@oss.qualcomm.com>,
Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Subject: [PATCH v3 5/5] tests/tcg/hexagon: check the two HVX predicate build paths agree
Date: Thu, 3 Sep 2026 18:22:33 -0700 [thread overview]
Message-ID: <20260904012233.3607547-6-brian.cain@oss.qualcomm.com> (raw)
In-Reply-To: <20260904012233.3607547-1-brian.cain@oss.qualcomm.com>
A Q reg can be built by a vector compare or by vand(Vu, Rt), and
those reach the predicate register through independent code paths. Check
that both select the same byte lanes, so a byte-order mistake in either
one is caught.
The input alternates every eight lanes: a flatter pattern
stays unchanged when predicate bytes are permuted and hides the bug.
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
tests/tcg/hexagon/hvx_misc.c | 45 ++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/tests/tcg/hexagon/hvx_misc.c b/tests/tcg/hexagon/hvx_misc.c
index 32a3661a86f..225666137c9 100644
--- a/tests/tcg/hexagon/hvx_misc.c
+++ b/tests/tcg/hexagon/hvx_misc.c
@@ -181,6 +181,50 @@ static void test_store_unaligned(void)
check_output_w(__LINE__, 2);
}
+/*
+ * A Q register can be built either by a vector compare or by vand(Vu, Rt).
+ * Those are two independent code paths onto the same predicate-register
+ * layout, so cross-check that they select exactly the same byte lanes.
+ * A byte-order mistake in either one shows up here as a mismatch.
+ *
+ * The input pattern has to vary across 8-lane blocks, otherwise a predicate
+ * whose bytes are permuted still selects the same lanes and the mismatch is
+ * invisible.
+ */
+static void test_qreg_alias(void)
+{
+ HVX_Vector *pcmp = (HVX_Vector *)&output[0];
+ HVX_Vector *pand = (HVX_Vector *)&output[1];
+ HVX_Vector input;
+ HVX_Vector ones;
+ HVX_VectorPred qcmp;
+ HVX_VectorPred qand;
+
+ for (int i = 0; i < BUFSIZE; i++) {
+ /*
+ * Build 0/1 per byte, alternating every 8 lanes, so that "!= 0" and
+ * "low bit set" describe the same lanes. Then form one predicate
+ * with a compare and the other with vand(Vu, Rt), store 0xff through
+ * each, and require the two result vectors to be identical.
+ */
+ for (int j = 0; j < MAX_VEC_SIZE_BYTES; j++) {
+ expect[0].ub[j] = ((j >> 3) + i) & 1;
+ }
+ memcpy(&input, &expect[0], sizeof(MMVector));
+ memset(output, 0, 2 * sizeof(MMVector));
+
+ ones = Q6_V_vsplat_R(0xffffffff);
+ qcmp = Q6_Q_vcmp_gt_VubVub(input, Q6_V_vzero());
+ qand = Q6_Q_vand_VR(input, 0x01010101);
+ Q6_vmem_QRIV(qcmp, pcmp, ones);
+ Q6_vmem_QRIV(qand, pand, ones);
+
+ for (int j = 0; j < MAX_VEC_SIZE_BYTES; j++) {
+ check(__LINE__, i, j, output[0].ub[j], output[1].ub[j]);
+ }
+ }
+}
+
static void test_masked_store(bool invert)
{
void *p0 = buffer0;
@@ -579,6 +623,7 @@ int main()
test_store_unaligned();
test_masked_store(false);
test_masked_store(true);
+ test_qreg_alias();
test_new_value_store();
test_max_temps();
--
2.34.1
next prev parent reply other threads:[~2026-09-04 1:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 1:22 [PATCH v3 0/5] hexagon: fix HVX scatter gather, BE host Brian Cain
2026-09-04 1:22 ` [PATCH v3 1/5] target/hexagon: fix HVX big-endian byte access Brian Cain
2026-09-04 1:22 ` [PATCH v3 2/5] target/hexagon: fix HVX scatter/gather region-length check Brian Cain
2026-09-04 10:33 ` Philippe Mathieu-Daudé
2026-09-04 22:22 ` Brian Cain
2026-09-04 1:22 ` [PATCH v3 3/5] tests/tcg/hexagon: add vgather/vscatter region-length tests Brian Cain
2026-09-04 5:50 ` Pierrick Bouvier
2026-09-04 1:22 ` [PATCH v3 4/5] target/hexagon: fix HVX predicate save size for histogram ops Brian Cain
2026-09-04 1:22 ` Brian Cain [this message]
2026-09-04 5:51 ` [PATCH v3 5/5] tests/tcg/hexagon: check the two HVX predicate build paths agree Pierrick Bouvier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260904012233.3607547-6-brian.cain@oss.qualcomm.com \
--to=brian.cain@oss.qualcomm.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.