From nobody Tue Feb 10 04:08:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@quicinc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1658184750; cv=none; d=zohomail.com; s=zohoarc; b=BbGV5dSFyE+7v1Od3kDMp0BFjdNlUt1swEB5FVPwS6Uw3MRA3Fv0euD9Ib60pGBuj4X+0j+WhaX7Z203XkYJlj5n582EDVtRBNTf37gfC187tc49qdP5lYamaiG8TqHoaLKrRGZnTMFeAn5c0p7XHRbGBFfBolBpezL48JsKcAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658184750; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d6FaWUOag8iP/9WOQBkQciYmECIUHkxz2/ziesNytL0=; b=gjRHwyq0n7LLiGm/eD6oxHyL4PL8DjE7t4XguCJH3D4aqPt+5OkqJPTfdXAzcts1VkKKvHndkHoklRcDLv4w2twsFtzo4GqCkUGJ99WNGWZv86wF49U+nJTi5mqCi1RLGIsP6MyRhKYvreP8hZrcWbZ9j6r9/dtjCMECStF3wuw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@quicinc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658184750798565.3352615968129; Mon, 18 Jul 2022 15:52:30 -0700 (PDT) Received: from localhost ([::1]:58480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDZbJ-0003c4-FE for importer@patchew.org; Mon, 18 Jul 2022 18:52:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDZYG-0008Jz-QK for qemu-devel@nongnu.org; Mon, 18 Jul 2022 18:49:20 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:16625) by eggs.gnu.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1oDZYE-0003Ip-UG for qemu-devel@nongnu.org; Mon, 18 Jul 2022 18:49:20 -0400 Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 18 Jul 2022 15:49:07 -0700 Received: from hu-tsimpson-lv.qualcomm.com (HELO hu-devc-lv-u18-c.qualcomm.com) ([10.47.235.220]) by ironmsg08-lv.qualcomm.com with ESMTP; 18 Jul 2022 15:49:07 -0700 Received: by hu-devc-lv-u18-c.qualcomm.com (Postfix, from userid 47164) id 4F10C5005B7; Mon, 18 Jul 2022 15:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1658184559; x=1689720559; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d6FaWUOag8iP/9WOQBkQciYmECIUHkxz2/ziesNytL0=; b=gVNPmSq+Co5HUqKSk8Qg9bmULwR5CA4e+GcNelMsRYPvYngGw3bnND46 Mio7ODGvUQTuWGqd7VbcGnUrD+1C/fRpNvTAiY/Sd665OioGb1bpx5Coc +83PCH5cisuVgu0v7QZ61Vlo7KX8YuJu9ZwefE3UwKYjNnuoPhmEDIepD w=; X-QCInternal: smtphost From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, f4bug@amsat.org, peter.maydell@linaro.org, Brian Cain Subject: [PULL 1/2] Hexagon (target/hexagon) fix store w/mem_noshuf & predicated load Date: Mon, 18 Jul 2022 15:48:44 -0700 Message-Id: <20220718224845.19878-2-tsimpson@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220718224845.19878-1-tsimpson@quicinc.com> References: <20220718224845.19878-1-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=129.46.98.28; envelope-from=tsimpson@qualcomm.com; helo=alexa-out.qualcomm.com X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @quicinc.com) X-ZM-MESSAGEID: 1658184752294100001 Call the CHECK_NOSHUF macro multiple times: once in the fGEN_TCG_PRED_LOAD() and again in fLOAD(). Before this commit, a packet with a store and a predicated load with mem_noshuf that gets encoded like this: { P0 =3D cmp.eq(R17,#0x0) memw(R18+#0x0) =3D R2 if (!P0.new) R3 =3D memw(R17+#0x4) } ... would end up generating a branch over both the load and the store like so: ... brcond_i32 loc17,$0x0,eq,$L1 mov_i32 loc18,store_addr_1 qemu_st_i32 store_val32_1,store_addr_1,leul,0 qemu_ld_i32 loc16,loc7,leul,0 set_label $L1 ... Test cases added to tests/tcg/hexagon/mem_noshuf.c Co-authored-by: Taylor Simpson Signed-off-by: Brian Cain Signed-off-by: Taylor Simpson Reviewed-by: Richard Henderson Message-Id: <20220707210546.15985-2-tsimpson@quicinc.com> --- target/hexagon/gen_tcg.h | 2 + tests/tcg/hexagon/mem_noshuf.c | 122 +++++++++++++++++++++++++++++++-- 2 files changed, 119 insertions(+), 5 deletions(-) diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h index c6f0879b6e..b0b6b3644e 100644 --- a/target/hexagon/gen_tcg.h +++ b/target/hexagon/gen_tcg.h @@ -343,6 +343,7 @@ PRED; \ PRED_LOAD_CANCEL(LSB, EA); \ tcg_gen_movi_tl(RdV, 0); \ + CHECK_NOSHUF; \ tcg_gen_brcondi_tl(TCG_COND_EQ, LSB, 0, label); \ fLOAD(1, SIZE, SIGN, EA, RdV); \ gen_set_label(label); \ @@ -402,6 +403,7 @@ PRED; \ PRED_LOAD_CANCEL(LSB, EA); \ tcg_gen_movi_i64(RddV, 0); \ + CHECK_NOSHUF; \ tcg_gen_brcondi_tl(TCG_COND_EQ, LSB, 0, label); \ fLOAD(1, 8, u, EA, RddV); \ gen_set_label(label); \ diff --git a/tests/tcg/hexagon/mem_noshuf.c b/tests/tcg/hexagon/mem_noshuf.c index dd714d5e98..0f4064e700 100644 --- a/tests/tcg/hexagon/mem_noshuf.c +++ b/tests/tcg/hexagon/mem_noshuf.c @@ -1,5 +1,5 @@ /* - * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Res= erved. + * Copyright(c) 2019-2022 Qualcomm Innovation Center, Inc. All Rights Res= erved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -84,6 +84,70 @@ MEM_NOSHUF32(mem_noshuf_sd_luh, long long, unsigned s= hort, memd, memuh) MEM_NOSHUF32(mem_noshuf_sd_lw, long long, signed int, memd, memw) MEM_NOSHUF64(mem_noshuf_sd_ld, long long, signed long long, memd, memd) =20 +static inline int pred_lw_sw(int pred, int *p, int *q, int x, int y) +{ + int ret; + asm volatile("p0 =3D cmp.eq(%5, #0)\n\t" + "%0 =3D %3\n\t" + "{\n\t" + " memw(%1) =3D %4\n\t" + " if (!p0) %0 =3D memw(%2)\n\t" + "}:mem_noshuf\n" + : "=3D&r"(ret) + : "r"(p), "r"(q), "r"(x), "r"(y), "r"(pred) + : "p0", "memory"); + return ret; +} + +static inline int pred_lw_sw_pi(int pred, int *p, int *q, int x, int y) +{ + int ret; + asm volatile("p0 =3D cmp.eq(%5, #0)\n\t" + "%0 =3D %3\n\t" + "r7 =3D %2\n\t" + "{\n\t" + " memw(%1) =3D %4\n\t" + " if (!p0) %0 =3D memw(r7++#4)\n\t" + "}:mem_noshuf\n" + : "=3D&r"(ret) + : "r"(p), "r"(q), "r"(x), "r"(y), "r"(pred) + : "r7", "p0", "memory"); + return ret; +} + +static inline long long pred_ld_sd(int pred, long long *p, long long *q, + long long x, long long y) +{ + unsigned long long ret; + asm volatile("p0 =3D cmp.eq(%5, #0)\n\t" + "%0 =3D %3\n\t" + "{\n\t" + " memd(%1) =3D %4\n\t" + " if (!p0) %0 =3D memd(%2)\n\t" + "}:mem_noshuf\n" + : "=3D&r"(ret) + : "r"(p), "r"(q), "r"(x), "r"(y), "r"(pred) + : "p0", "memory"); + return ret; +} + +static inline long long pred_ld_sd_pi(int pred, long long *p, long long *q, + long long x, long long y) +{ + long long ret; + asm volatile("p0 =3D cmp.eq(%5, #0)\n\t" + "%0 =3D %3\n\t" + "r7 =3D %2\n\t" + "{\n\t" + " memd(%1) =3D %4\n\t" + " if (!p0) %0 =3D memd(r7++#8)\n\t" + "}:mem_noshuf\n" + : "=3D&r"(ret) + : "r"(p), "r"(q), "r"(x), "r"(y), "r"(pred) + : "p0", "memory"); + return ret; +} + static inline unsigned int cancel_sw_lb(int pred, int *p, signed char *q, = int x) { unsigned int ret; @@ -126,18 +190,22 @@ typedef union { =20 int err; =20 -static void check32(int n, int expect) +#define check32(n, expect) check32_(n, expect, __LINE__) + +static void check32_(int n, int expect, int line) { if (n !=3D expect) { - printf("ERROR: 0x%08x !=3D 0x%08x\n", n, expect); + printf("ERROR: 0x%08x !=3D 0x%08x, line %d\n", n, expect, line); err++; } } =20 -static void check64(long long n, long long expect) +#define check64(n, expect) check64_(n, expect, __LINE__) + +static void check64_(long long n, long long expect, int line) { if (n !=3D expect) { - printf("ERROR: 0x%08llx !=3D 0x%08llx\n", n, expect); + printf("ERROR: 0x%08llx !=3D 0x%08llx, line %d\n", n, expect, line= ); err++; } } @@ -323,6 +391,50 @@ int main() res64 =3D mem_noshuf_sd_ld(&n.d[0], &n.d[1], 0x123456789abcdef0LL); check64(res64, 0xffffffffffffffffLL); =20 + n.w[0] =3D ~0; + res32 =3D pred_lw_sw(0, &n.w[0], &n.w[0], 0x12345678, 0xc0ffeeda); + check32(res32, 0x12345678); + check32(n.w[0], 0xc0ffeeda); + + n.w[0] =3D ~0; + res32 =3D pred_lw_sw(1, &n.w[0], &n.w[0], 0x12345678, 0xc0ffeeda); + check32(res32, 0xc0ffeeda); + check32(n.w[0], 0xc0ffeeda); + + n.w[0] =3D ~0; + res32 =3D pred_lw_sw_pi(0, &n.w[0], &n.w[0], 0x12345678, 0xc0ffeeda); + check32(res32, 0x12345678); + check32(n.w[0], 0xc0ffeeda); + + n.w[0] =3D ~0; + res32 =3D pred_lw_sw_pi(1, &n.w[0], &n.w[0], 0x12345678, 0xc0ffeeda); + check32(res32, 0xc0ffeeda); + check32(n.w[0], 0xc0ffeeda); + + n.d[0] =3D ~0LL; + res64 =3D pred_ld_sd(0, &n.d[0], &n.d[0], + 0x1234567812345678LL, 0xc0ffeedac0ffeedaLL); + check64(res64, 0x1234567812345678LL); + check64(n.d[0], 0xc0ffeedac0ffeedaLL); + + n.d[0] =3D ~0LL; + res64 =3D pred_ld_sd(1, &n.d[0], &n.d[0], + 0x1234567812345678LL, 0xc0ffeedac0ffeedaLL); + check64(res64, 0xc0ffeedac0ffeedaLL); + check64(n.d[0], 0xc0ffeedac0ffeedaLL); + + n.d[0] =3D ~0LL; + res64 =3D pred_ld_sd_pi(0, &n.d[0], &n.d[0], + 0x1234567812345678LL, 0xc0ffeedac0ffeedaLL); + check64(res64, 0x1234567812345678LL); + check64(n.d[0], 0xc0ffeedac0ffeedaLL); + + n.d[0] =3D ~0LL; + res64 =3D pred_ld_sd_pi(1, &n.d[0], &n.d[0], + 0x1234567812345678LL, 0xc0ffeedac0ffeedaLL); + check64(res64, 0xc0ffeedac0ffeedaLL); + check64(n.d[0], 0xc0ffeedac0ffeedaLL); + puts(err ? "FAIL" : "PASS"); return err; } --=20 2.17.1