From patchwork Tue Mar 17 19:00:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 184667 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4503216ile; Tue, 17 Mar 2020 12:03:19 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuhxGIGht2GNrXtEJMRbCEHaY7IcX+RRWDJu9tPgmbArfPDOsx9MH8d9E7aVNu+gvEv9o+Y X-Received: by 2002:ad4:4802:: with SMTP id g2mr596747qvy.95.1584471799765; Tue, 17 Mar 2020 12:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584471799; cv=none; d=google.com; s=arc-20160816; b=G94K07ACNsURrDSsmUZqkDtA1Qg2BZAlLYN+6UzBtt1/cIHEpVWdxkXx8HM0UiuYx5 XcbOYpJQnISqrAymB8dZgYeLb5raN9QxFvbPAJBhNYjt4AReIUZOL77XHWyxhuts9PT+ 2afygSNE5V4rWeUEPgL0kIn0gHmOUM7AG9EGoZAQVy9H710eB8NyQvLVKpWjzvuwU879 OnE43gd3fdLh5EjNMAYHxmnDJa5D9H0sb+qbFt9GGAW5jzpf8cdsuLR/Wj7veXPNSFAG ehjZE3fW+fpd59UuAtdNMJ10nlcaBXC4tOHm2VbPBv+O0gUDxQ+RzCkcO3WkAlYJtrbk RzyA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=wcSaDLPBm27zUZG4KbOwcxrAEQmHL3Xru2iiSqgStcQ=; b=Kw2ACspZYEmHxrcuqe8bh9G1On9j9Ur9xmmyl2GBlmRREtJN79xROTVyCP4LHXr4yQ qLXN/Wz0Jaxc32I3V/hchboDDWPfj5d6jrtuGf66twqdc/ppjKcUBU3E0I6eWic3UsQj DLHfS8pm6rTyxAwgOj3jJwMvC38aN0j5jwGI5t2oKYay/dlRuGrKW34bJoaAr8pfCWwq hKwFn8YL7kjClIOmdd0iBDB+h0GjiCNXsHUkrq1H7kpZnAROyMoSwJQDbU+e7Haj5nsR 0zLHiwjWUT4k0CwpgwLUCHXSW9Lc4xqFS6PnncKhmtWVihiBwRUSEOcWVFNP7msrTSis fbTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NXoB5wxB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u1si2616855qku.190.2020.03.17.12.03.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 12:03:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NXoB5wxB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEHUl-00024S-7G for patch@linaro.org; Tue, 17 Mar 2020 15:03:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33186) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEHRr-0007Bv-DI for qemu-devel@nongnu.org; Tue, 17 Mar 2020 15:00:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEHRq-00046G-66 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 15:00:19 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:36486) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEHRp-000408-VK for qemu-devel@nongnu.org; Tue, 17 Mar 2020 15:00:18 -0400 Received: by mail-pl1-x636.google.com with SMTP id g2so7512203plo.3 for ; Tue, 17 Mar 2020 12:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wcSaDLPBm27zUZG4KbOwcxrAEQmHL3Xru2iiSqgStcQ=; b=NXoB5wxBCgZQNc7gAazD6xA7pEoA0CDon+/SeDGlPyIzjkKl8NQ41rg0YXOsUmrv9n 3q/zZ32ZYTnmqou0M0Nn5vDpXqZJ19jyH1eGg0K4k0cn7U+px7/Twq8m1wBVzQUYcE4D 21PgKbgLlymNQLLD9h2eppDpzz0IAqpssGeI5ELD3qQSSQEzfLxirhxsyE86SdijhLE9 rWv0etWYXw46agSPG5SCqRJyqQIwmbsj3jZXg+xRxzfvKQRzy+dgshReLUlWcF0DePLi 8j0eStbBs+cOPEDjn+Oqz8GP9RT9IP/cF3u1P2/PQgRDrrulpYIPX6Bq0eli97z4RXU3 ksfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wcSaDLPBm27zUZG4KbOwcxrAEQmHL3Xru2iiSqgStcQ=; b=HWmO2Ywqg4NkimM6SgdUwHH8ukI5UJQ8P/7gcrJDGMrOCndmpatYpoTKi5l5twFdnH xng6h2JAlcBJKj85aFj6aRMUPaoIA7fB7xjGNJNfg16P3ErlO+foJjTA51VdEi283bg2 qaBDi6KglzdjHuLAamWOCTbQ2dyyu2bVHK6N1rnZPedeawe0t6G/koXqd/F8MuJCGBVK BXlEiqnissnaKRUgns2S34q9xz4wAMAe0DHdR5AgviR2r4uRMfwnt3jl1FL4sadg1JXm JFLAqr21ebEsYnYLzXVnafuovWYdqRQUQ+M903vPllj8x9PbbJRZ6DbHqoV9FM3UubyK b0Uw== X-Gm-Message-State: ANhLgQ0HwQoU51gIvYwvUuw95yJUraqtqDt7kc7pPMh2QYkOYaCAJgA9 t5uqNmlfBTKoLOzACWuOgkms7nVkqjM= X-Received: by 2002:a17:902:444:: with SMTP id 62mr88213ple.109.1584471616598; Tue, 17 Mar 2020 12:00:16 -0700 (PDT) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id y13sm3738411pfp.88.2020.03.17.12.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 12:00:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 1/5] tcg/i386: Bound shift count expanding sari_vec Date: Tue, 17 Mar 2020 12:00:09 -0700 Message-Id: <20200317190013.25036-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317190013.25036-1-richard.henderson@linaro.org> References: <20200317190013.25036-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::636 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" A given RISU testcase for SVE can produce tcg-op-vec.c:511: do_shifti: Assertion `i >= 0 && i < (8 << vece)' failed. because expand_vec_sari gave a shift count of 32 to a MO_32 vector shift. In 44f1441dbe1, we changed from direct expansion of vector opcodes to re-use of the tcg expanders. So while the comment correctly notes that the hw will handle such a shift count, we now have to take our own sanity checks into account. Which is easy in this particular case. Fixes: 44f1441dbe1 Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.inc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index cdedcb2b25..223dba9c8c 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -3391,12 +3391,15 @@ static void expand_vec_sari(TCGType type, unsigned vece, case MO_64: if (imm <= 32) { - /* We can emulate a small sign extend by performing an arithmetic + /* + * We can emulate a small sign extend by performing an arithmetic * 32-bit shift and overwriting the high half of a 64-bit logical - * shift (note that the ISA says shift of 32 is valid). + * shift. Note that the ISA says shift of 32 is valid, but TCG + * does not, so we have to bound the smaller shift -- we get the + * same result in the high half either way. */ t1 = tcg_temp_new_vec(type); - tcg_gen_sari_vec(MO_32, t1, v1, imm); + tcg_gen_sari_vec(MO_32, t1, v1, MIN(imm, 31)); tcg_gen_shri_vec(MO_64, v0, v1, imm); vec_gen_4(INDEX_op_x86_blend_vec, type, MO_32, tcgv_vec_arg(v0), tcgv_vec_arg(v0),