From patchwork Sat Jan 14 19:16:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Wilson X-Patchwork-Id: 18902 Received: (qmail 93532 invoked by alias); 14 Jan 2017 19:16:25 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 91196 invoked by uid 89); 14 Jan 2017 19:16:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=1, 50, reserved X-HELO: mail-yb0-f171.google.com Received: from mail-yb0-f171.google.com (HELO mail-yb0-f171.google.com) (209.85.213.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 14 Jan 2017 19:16:13 +0000 Received: by mail-yb0-f171.google.com with SMTP id w194so20385978ybe.0 for ; Sat, 14 Jan 2017 11:16:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=1td886As8ssLGKj6Fd8WwZ6pOloPbTV6mRUAtOlZUjE=; b=d9PaJicmRqdUWja7Pcni92OVSTqQYGOioMGdlkG1u96kGNtIe2dHkU3FX3qzREvz6x PNs9ecQ6PwNiBA0QvHWcMEy7aTRuMtedz6FGnVNIIlBtkg8qresBpWlWFOAXtGfdCL6E VmYuFBVBqSKfcBWCm0wwqBNgzvx48cQj7j6hKd9aq2+KCzIMgFM9Q9g0Q0jMneIZyX2S benp4reJ12tGgtAE4JsDw38+VAWvS19iNSxWNWMbCF4Xm74J2iAJfjBUA/wGbe71jH+w 2tFXm/o/qPbg3hgO945hmP6nNDRuotg5YRGWY22QZeirMjFCBf3uI4/RCJlZ3StwxbRJ 3yZA== X-Gm-Message-State: AIkVDXI1sSsSXS/RipPzACKCULV8ksSMPpMkdgG4rCwb3eRzMtcN7bAq09lwU/Tf3eLt87bOnAqo3GoI8hHMuPHo X-Received: by 10.37.170.225 with SMTP id t88mr9021627ybi.74.1484421371862; Sat, 14 Jan 2017 11:16:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.92.4 with HTTP; Sat, 14 Jan 2017 11:16:11 -0800 (PST) From: Jim Wilson Date: Sat, 14 Jan 2017 11:16:11 -0800 Message-ID: Subject: [PATCH] aarch64 sim addv bug fix To: gdb-patches@sourceware.org Cc: Nick Clifton The addv instruction is storing results to general registers instead of vector registers. The reserved instruction check is wrong, It should be not full in case 2, and unconditionally in case 3. The testcase fails without the patch, and works with the patch. The patch reduces gcc C testsuite failures from 2227 to 2174 (-57). Jim sim/aarch64/ * simulator.c (do_vec_ADDV): Call aarch64_set_vec_u64 instead of aarch64_set_reg_u64. In case 2, call HALT_UNALLOC if not full. In case 3, call HALT_UNALLOC unconditionally. sim/testsuite/sim/aarch64/ * addv.s: New. diff --git a/sim/aarch64/simulator.c b/sim/aarch64/simulator.c index 36129e5..6237c09 100644 --- a/sim/aarch64/simulator.c +++ b/sim/aarch64/simulator.c @@ -3445,28 +3445,25 @@ do_vec_ADDV (sim_cpu *cpu) case 0: for (i = 0; i < (full ? 16 : 8); i++) val += aarch64_get_vec_u8 (cpu, vm, i); - aarch64_set_reg_u64 (cpu, rd, NO_SP, val); + aarch64_set_vec_u64 (cpu, rd, 0, val); return; case 1: for (i = 0; i < (full ? 8 : 4); i++) val += aarch64_get_vec_u16 (cpu, vm, i); - aarch64_set_reg_u64 (cpu, rd, NO_SP, val); + aarch64_set_vec_u64 (cpu, rd, 0, val); return; case 2: - for (i = 0; i < (full ? 4 : 2); i++) + if (! full) + HALT_UNALLOC; + for (i = 0; i < 4; i++) val += aarch64_get_vec_u32 (cpu, vm, i); - aarch64_set_reg_u64 (cpu, rd, NO_SP, val); + aarch64_set_vec_u64 (cpu, rd, 0, val); return; case 3: - if (! full) - HALT_UNALLOC; - val = aarch64_get_vec_u64 (cpu, vm, 0); - val += aarch64_get_vec_u64 (cpu, vm, 1); - aarch64_set_reg_u64 (cpu, rd, NO_SP, val); - return; + HALT_UNALLOC; } } diff --git a/sim/testsuite/sim/aarch64/addv.s b/sim/testsuite/sim/aarch64/addv.s new file mode 100644 index 0000000..4da8935 --- /dev/null +++ b/sim/testsuite/sim/aarch64/addv.s @@ -0,0 +1,50 @@ +# mach: aarch64 + +# Check the add across vector instruction: addv. + +.include "testutils.inc" + + .data + .align 4 +input: + .word 0x04030201 + .word 0x08070605 + .word 0x0c0b0a09 + .word 0x100f0e0d + + start + adrp x0, input + ldr q0, [x0, #:lo12:input] + + addv b1, v0.8b + mov x1, v1.d[0] + cmp x1, #36 + bne .Lfailure + + addv b1, v0.16b + mov x1, v1.d[0] + cmp x1, #136 + bne .Lfailure + + addv h1, v0.4h + mov x1, v1.d[0] + mov x2, #5136 + cmp x1, x2 + bne .Lfailure + + addv h1, v0.8h + mov x1, v1.d[0] + mov x2, #18496 + cmp x1, x2 + bne .Lfailure + + addv s1, v0.4s + mov x1, v1.d[0] + mov x2, 8220 + movk x2, 0x2824, lsl 16 + cmp x1, x2 + bne .Lfailure + + pass +.Lfailure: + fail