Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Wilson <jim.wilson@linaro.org>
To: gdb-patches@sourceware.org
Cc: Nick Clifton <nickc@redhat.com>
Subject: [PATCH] aarch64 sim vector mul bug fix
Date: Sat, 24 Dec 2016 22:24:00 -0000	[thread overview]
Message-ID: <CABXYE2XBaxNvZmWYAJ=0wGMzX0k0+2w=ODsLh57C_VFVqwW-Wg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

The vector mul instruction is doing a widening multiply, but isn't
supposed to.  mull does a widening multiply, mul does a regular
multiply.

The testcase works with the patch, and fails without the patch.  GCC C
testsuite failures drop from 2538 to 2473.

Jim

[-- Attachment #2: aarch64-sim-mul.patch --]
[-- Type: text/x-patch, Size: 2743 bytes --]

2016-12-23  Jim Wilson  <jim.wilson@linaro.org>

	sim/aarch64/
	* simulator.c (do_vec_mul): In all DO_VEC_WIDENING_MUL calls, make
	second and fourth args same size as third arg.

	sim/testsuite/sim/aarch64/
	* mul.s: New.

diff --git a/sim/aarch64/simulator.c b/sim/aarch64/simulator.c
index be3d6c7..9da12d3 100644
--- a/sim/aarch64/simulator.c
+++ b/sim/aarch64/simulator.c
@@ -3724,15 +3724,15 @@ do_vec_mul (sim_cpu *cpu)
   switch (INSTR (23, 22))
     {
     case 0:
-      DO_VEC_WIDENING_MUL (full ? 16 : 8, uint16_t, u8, u16);
+      DO_VEC_WIDENING_MUL (full ? 16 : 8, uint8_t, u8, u8);
       return;
 
     case 1:
-      DO_VEC_WIDENING_MUL (full ? 8 : 4, uint32_t, u16, u32);
+      DO_VEC_WIDENING_MUL (full ? 8 : 4, uint16_t, u16, u16);
       return;
 
     case 2:
-      DO_VEC_WIDENING_MUL (full ? 4 : 2, uint64_t, u32, u64);
+      DO_VEC_WIDENING_MUL (full ? 4 : 2, uint32_t, u32, u32);
       return;
 
     case 3:
diff --git a/sim/testsuite/sim/aarch64/mul.s b/sim/testsuite/sim/aarch64/mul.s
new file mode 100644
index 0000000..783dba7
--- /dev/null
+++ b/sim/testsuite/sim/aarch64/mul.s
@@ -0,0 +1,99 @@
+# mach: aarch64
+
+# Check the non-widening multiply vector instruction: mul.
+
+.include "testutils.inc"
+
+	.data
+	.align 4
+input:
+	.word 0x04030201
+	.word 0x08070605
+	.word 0x0c0b0a09
+	.word 0x100f0e0d
+m8b:
+	.word 0x10090401
+	.word 0x40312419
+m16b:
+	.word 0x10090401
+	.word 0x40312419
+	.word 0x90796451
+	.word 0x00e1c4a9
+m4h:
+	.word 0x18090401
+	.word 0x70313c19
+m8h:
+	.word 0x18090401
+	.word 0x70313c19
+	.word 0x0879b451
+	.word 0xe0e16ca9
+m2s:
+	.word 0x140a0401
+	.word 0xa46a3c19
+m4s:
+	.word 0x140a0401
+	.word 0xa46a3c19
+	.word 0xb52ab451
+	.word 0x464b6ca9
+
+	start
+	adrp x0, input
+	ldr q0, [x0, #:lo12:input]
+
+	mul v1.8b, v0.8b, v0.8b
+	mov x1, v1.d[0]
+	adrp x3, m8b
+	ldr x4, [x0, #:lo12:m8b]
+	cmp x1, x4
+	bne .Lfailure
+
+	mul v1.16b, v0.16b, v0.16b
+	mov x1, v1.d[0]
+	mov x2, v1.d[1]
+	adrp x3, m16b
+	ldr x4, [x0, #:lo12:m16b]
+	cmp x1, x4
+	bne .Lfailure
+	ldr x5, [x0, #:lo12:m16b+8]
+	cmp x2, x5
+	bne .Lfailure
+
+	mul v1.4h, v0.4h, v0.4h
+	mov x1, v1.d[0]
+	adrp x3, m4h
+	ldr x4, [x0, #:lo12:m4h]
+	cmp x1, x4
+	bne .Lfailure
+
+	mul v1.8h, v0.8h, v0.8h
+	mov x1, v1.d[0]
+	mov x2, v1.d[1]
+	adrp x3, m8h
+	ldr x4, [x0, #:lo12:m8h]
+	cmp x1, x4
+	bne .Lfailure
+	ldr x5, [x0, #:lo12:m8h+8]
+	cmp x2, x5
+	bne .Lfailure
+
+	mul v1.2s, v0.2s, v0.2s
+	mov x1, v1.d[0]
+	adrp x3, m2s
+	ldr x4, [x0, #:lo12:m2s]
+	cmp x1, x4
+	bne .Lfailure
+
+	mul v1.4s, v0.4s, v0.4s
+	mov x1, v1.d[0]
+	mov x2, v1.d[1]
+	adrp x3, m4s
+	ldr x4, [x0, #:lo12:m4s]
+	cmp x1, x4
+	bne .Lfailure
+	ldr x5, [x0, #:lo12:m4s+8]
+	cmp x2, x5
+	bne .Lfailure
+
+	pass
+.Lfailure:
+	fail

             reply	other threads:[~2016-12-24 22:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-24 22:24 Jim Wilson [this message]
2017-01-03 14:35 ` Nick Clifton
2017-01-05  0:13   ` Jim Wilson
     [not found]     ` <a68cfc77-a1b9-0163-c6a3-90a687b97e8b@redhat.com>
2017-02-14 18:24       ` Mike Frysinger

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='CABXYE2XBaxNvZmWYAJ=0wGMzX0k0+2w=ODsLh57C_VFVqwW-Wg@mail.gmail.com' \
    --to=jim.wilson@linaro.org \
    --cc=gdb-patches@sourceware.org \
    --cc=nickc@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox