diff mbox series

[2/2] Add test for storing .new vector

Message ID 20230321141206.751719-3-quic_mliebel@quicinc.com
State New
Headers show
Series Update hexagon toolchain | expand

Commit Message

Marco Liebel March 21, 2023, 2:12 p.m. UTC
Hexagon toolchain version 16.0.0 fixes a bug where the ecoding of
storing a .new vector was incorrect. This resulted in an incorrect
valued being stored. The test checks that the correct value is used.

Signed-off-by: Marco Liebel <quic_mliebel@quicinc.com>
---
 tests/tcg/hexagon/hvx_misc.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Comments

Taylor Simpson March 21, 2023, 4:52 p.m. UTC | #1
> -----Original Message-----
> From: Marco Liebel (QUIC) <quic_mliebel@quicinc.com>
> Sent: Tuesday, March 21, 2023 8:12 AM
> To: qemu-devel@nongnu.org
> Cc: Taylor Simpson <tsimpson@quicinc.com>; Matheus Bernardino (QUIC)
> <quic_mathbern@quicinc.com>; Marco Liebel (QUIC)
> <quic_mliebel@quicinc.com>
> Subject: [PATCH 2/2] Add test for storing .new vector
> 
> Hexagon toolchain version 16.0.0 fixes a bug where the ecoding of storing a
> .new vector was incorrect. This resulted in an incorrect valued being stored.
> The test checks that the correct value is used.
> 
> Signed-off-by: Marco Liebel <quic_mliebel@quicinc.com>
> ---
>  tests/tcg/hexagon/hvx_misc.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/tests/tcg/hexagon/hvx_misc.c b/tests/tcg/hexagon/hvx_misc.c
> index 53d5c9b44f..657e556dd4 100644
> --- a/tests/tcg/hexagon/hvx_misc.c
> +++ b/tests/tcg/hexagon/hvx_misc.c
> @@ -211,6 +211,34 @@ static void test_store_unaligned(void)
>      check_output_w(__LINE__, 2);
>  }
> 
> +static void test_store_new(void)
> +{
> +    asm volatile(
> +        "r0 = #0x00000003\n\t"
> +        "v0 = vsplat(r0)\n\t"
> +        "r0 = #expect\n\t"
> +        "vmem(r0+#0) = v0\n\t"

The idiom used in this file is the inline asm stores into the output buffer and there is vanilla C that writes to the expect buffer.  So, move the above to something like this (after the inline asm).
    for (int j = 0; I < MAX_VEC_SIZE_BYTES / 4; j++) {
        expect[0].w[j] = 3;
    }

Thanks,
Taylor
Peter Maydell March 21, 2023, 5:19 p.m. UTC | #2
On Tue, 21 Mar 2023 at 14:13, Marco Liebel <quic_mliebel@quicinc.com> wrote:
>
> Hexagon toolchain version 16.0.0 fixes a bug where the ecoding of
> storing a .new vector was incorrect. This resulted in an incorrect
> valued being stored. The test checks that the correct value is used.

So is this a compiler/assembler bug? Do we need to have tests
relating to those in QEMU's test suite ?

thanks
-- PMM
Marco Liebel March 21, 2023, 6:20 p.m. UTC | #3
> -----Original Message-----
> From: Peter Maydell <peter.maydell@linaro.org>
> Sent: Dienstag, 21. März 2023 18:20
> To: Marco Liebel (QUIC) <quic_mliebel@quicinc.com>
> Cc: qemu-devel@nongnu.org; Taylor Simpson <tsimpson@quicinc.com>;
> Matheus Bernardino (QUIC) <quic_mathbern@quicinc.com>
> Subject: Re: [PATCH 2/2] Add test for storing .new vector
> 
> WARNING: This email originated from outside of Qualcomm. Please be wary
> of any links or attachments, and do not enable macros.
> 
> On Tue, 21 Mar 2023 at 14:13, Marco Liebel <quic_mliebel@quicinc.com>
> wrote:
> >
> > Hexagon toolchain version 16.0.0 fixes a bug where the ecoding of
> > storing a .new vector was incorrect. This resulted in an incorrect
> > valued being stored. The test checks that the correct value is used.
> 
> So is this a compiler/assembler bug? Do we need to have tests
> relating to those in QEMU's test suite ?
> 
> thanks
> -- PMM

The bug was in the assembler. For the instruction that does the store of the
.new vector (vmem(r0+#0) = v3.new) it created the wrong output. So there
should be no need to have more tests, other than the one provided by this
patch.

Marco
diff mbox series

Patch

diff --git a/tests/tcg/hexagon/hvx_misc.c b/tests/tcg/hexagon/hvx_misc.c
index 53d5c9b44f..657e556dd4 100644
--- a/tests/tcg/hexagon/hvx_misc.c
+++ b/tests/tcg/hexagon/hvx_misc.c
@@ -211,6 +211,34 @@  static void test_store_unaligned(void)
     check_output_w(__LINE__, 2);
 }
 
+static void test_store_new(void)
+{
+    asm volatile(
+        "r0 = #0x00000003\n\t"
+        "v0 = vsplat(r0)\n\t"
+        "r0 = #expect\n\t"
+        "vmem(r0+#0) = v0\n\t"
+
+        "r0 = #output\n\t"
+        "r1 = #0x00000001\n\t"
+        "r2 = #0x00000002\n\t"
+        "r3 = #0x00000004\n\t"
+
+        "v1 = vsplat(r1)\n\t"
+        "v2 = vsplat(r2)\n\t"
+        "v3 = vsplat(r3)\n\t"
+
+        "{"
+        "   v3.w,q0 = vadd(v1.w, v2.w):carry\n\t"
+        "   vmem(r0+#0) = v3.new\n\t"
+        "}"
+
+        ::: "r0", "r1", "r2", "r3", "v0", "v1", "v2", "v3", "q0", "memory"
+    );
+
+    check_output_w(__LINE__, 1);
+}
+
 static void test_masked_store(bool invert)
 {
     void *p0 = buffer0;
@@ -620,6 +648,7 @@  int main()
     test_load_unaligned();
     test_store_aligned();
     test_store_unaligned();
+    test_store_new();
     test_masked_store(false);
     test_masked_store(true);
     test_new_value_store();