From patchwork Mon Jul 23 20:17:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 142638 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp6504153ljj; Mon, 23 Jul 2018 14:16:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf1xP/ABi+Qciff3HlVJIVaB3kYIEtMHTtimPbaBjnL7mYMLyDxOioQgiDLtt0Wg7kVNQ86 X-Received: by 2002:aed:3a24:: with SMTP id n33-v6mr14125429qte.348.1532380572273; Mon, 23 Jul 2018 14:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532380572; cv=none; d=google.com; s=arc-20160816; b=Lm9V9BPyw/M33CoN+8d3IAhljNRme+biJHoLJBqoaAvTlE37bFA+LJFFkdI3L0d0s1 WanxqvM2ODHM2Vat3x6u9OxCYTDOpAhxubq+D4UetYxbN5SyV//a25Bv1U2ks27X6S6z wXwddujsOKdvgiUyo5ns7IRn3a9JGCsv8tiwsBbr9uJjYzk5eWHBTdHm/SyPj7rUKeR0 wRx0uIYTYe//6Sj79IKfQaSFqn3m8THIrBo0LG7BdCc9lgUtcBCvgBn/zUCqYPL94/cM O1sAY0tj8fSTzlaPiShsbvI/RG9REauEsgvl6iZBKKG1UfBkkrnNHY4AgaX7qdrmx+OJ 7FGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=OppfwWBPBz1GOM6QzTsx+TJsOuHI0ZxTseXqqx+wcA4=; b=RBJinVRQ4lNJ0+GH+iNZQUfxLODW4DQ5g3uDsaDM+GlbRrm1pwMttBp2G/BrHhomTB ifPQ9iM5o1tXP3eTW+HaQv7v8QsIsW6NxqYysvWd2+X87gLxVEj7QLlZcSBft0YVztXY uZbsq3QSNgo8baGyIltyBWps5go2CNflJLFXEvucQfRmnF7JT3wmDZQ5nVi8Z+Rz4YQ9 13btMic5BH/6AOc5qu7psvvum+k+ka2SfrLfXqNh3F62rjonIVPyrAuURRSi6LlYpBCt 3/2AMGcCmgHqUG254ICou9AAP+L128qE1q6dpXlbeVru7gZhoiccvRzd2OhGNHPJ9arg Ya/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZQ2c32K5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s20-v6si9771602qvj.130.2018.07.23.14.16.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 23 Jul 2018 14:16:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZQ2c32K5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from localhost ([::1]:36684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiBf-0001z8-MU for patch@linaro.org; Mon, 23 Jul 2018 17:16:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKB-0003Q0-QU for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhK8-00052K-JM for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:55 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:38122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhK8-000520-E7; Mon, 23 Jul 2018 16:20:52 -0400 Received: by mail-oi0-x243.google.com with SMTP id v8-v6so3482212oie.5; Mon, 23 Jul 2018 13:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=OppfwWBPBz1GOM6QzTsx+TJsOuHI0ZxTseXqqx+wcA4=; b=ZQ2c32K5DisfX8WtGp11hAc3GBl+GgTjjOKh/Pdp7wH24qrdv7n2+54827dkDfx3qE iWX9QtNQgarObXvVc9bcfp1OgfPvEwnNAehY+642ELLkuM1tSNVzyOxNAau9CP1RoY0u W5mGIQitc4sD8BfipuIYlWx11A5+/NZWb4MK+Vv79B+VTu1S14N5uqzyiUZ3WYq1dINV ztqQry3h3YcWihb132qo1QVIP8km65CnUxcrfKeDnVuN4WnTbzqXbcMsfCXbyU6gdqNL Mr00X/njU5okT/yQrmSt9rokBK7da9gwFr24stjpvl8DsWFFaGb0Hs1D7eyzvzdxZDNS GQdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=OppfwWBPBz1GOM6QzTsx+TJsOuHI0ZxTseXqqx+wcA4=; b=e8XohEm7oTFgehRxtz5WxIZgjozKRTcygU65eMR8VVMsjnXqDp6CdId1geS/V5B3S8 SqmatwRaShv2uS0n802+IJq7+B9xz3qkSojHwpvVwUwozCQsU39nDjb4jqNM1v88NpeF 1TqlkTlVpRUOQ6jyNyqbjQxAvA732QXwNZGQE6VPG89RR7zU/I6PynduMFIVDRnFdfLc jX7kVlLf1/nNwWGDIdrABk+9TL98KQzHf2OU1iGmrdF0VxCbLpX6dIGMgH5C3IjZXn+w R+QPa+541y1yCGh1MOrZaM1jBwhQ5jp6ymdVQRy5YLr5m7Djood0std7bKL6yo2MuJXJ rT0w== X-Gm-Message-State: AOUpUlEhwMgbCZ55WZnORu8kwUZ/JwiiHUl3nhjwMtDjboUA0QxBj9y0 DUO/VYu2zioi7JC7h81BJYM46/YeesgyZg== X-Received: by 2002:aca:3b89:: with SMTP id i131-v6mr302123oia.109.1532377251221; Mon, 23 Jul 2018 13:20:51 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id o65-v6sm7411173oia.35.2018.07.23.13.20.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:50 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:13 -0500 Message-Id: <20180723201748.25573-65-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH 64/99] tcg/i386: Fix dup_vec in non-AVX2 codepath X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The VPUNPCKLD* instructions are all "non-destructive source", indicated by "NDS" in the encoding string in the x86 ISA manual. This means that they take two source operands, one of which is encoded in the VEX.vvvv field. We were incorrectly treating them as if they were destructive-source and passing 0 as the 'v' argument of tcg_out_vex_modrm(). This meant we were always using %xmm0 as one of the source operands, causing incorrect results if the register allocator happened to want to use something else. For instance the input AArch64 insn: DUP v26.16b, w21 which becomes TCG IR ops: dup_vec v128,e8,tmp2,x21 st_vec v128,e8,tmp2,env,$0xa40 was assembled to: 0x607c568c: c4 c1 7a 7e 86 e8 00 00 vmovq 0xe8(%r14), %xmm0 0x607c5694: 00 0x607c5695: c5 f9 60 c8 vpunpcklbw %xmm0, %xmm0, %xmm1 0x607c5699: c5 f9 61 c9 vpunpcklwd %xmm1, %xmm0, %xmm1 0x607c569d: c5 f9 70 c9 00 vpshufd $0, %xmm1, %xmm1 0x607c56a2: c4 c1 7a 7f 8e 40 0a 00 vmovdqu %xmm1, 0xa40(%r14) 0x607c56aa: 00 when the vpunpcklwd insn should be "%xmm1, %xmm1, %xmm1". This resulted in our incorrectly setting the output vector to q26=0000320000003200:0000320000003200 when given an input of x21 == 0000000002803200 rather than the expected all-zeroes. Pass the correct source register number to tcg_out_vex_modrm() for these insns. Fixes: 770c2fc7bb70804a Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Message-Id: <20180504153431.5169-1-peter.maydell@linaro.org> Signed-off-by: Richard Henderson (cherry picked from commit 7eb30ef0ba2eb59e7430d4848ae8d4bf4e50f768) Signed-off-by: Michael Roth --- tcg/i386/tcg-target.inc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index d7e59e79c5..5357909fff 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -854,11 +854,11 @@ static void tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, switch (vece) { case MO_8: /* ??? With zero in a register, use PSHUFB. */ - tcg_out_vex_modrm(s, OPC_PUNPCKLBW, r, 0, a); + tcg_out_vex_modrm(s, OPC_PUNPCKLBW, r, a, a); a = r; /* FALLTHRU */ case MO_16: - tcg_out_vex_modrm(s, OPC_PUNPCKLWD, r, 0, a); + tcg_out_vex_modrm(s, OPC_PUNPCKLWD, r, a, a); a = r; /* FALLTHRU */ case MO_32: @@ -867,7 +867,7 @@ static void tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out8(s, 0); break; case MO_64: - tcg_out_vex_modrm(s, OPC_PUNPCKLQDQ, r, 0, a); + tcg_out_vex_modrm(s, OPC_PUNPCKLQDQ, r, a, a); break; default: g_assert_not_reached();