From patchwork Wed Nov 15 14:28:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 165399 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2574508vqg; Wed, 15 Nov 2023 06:29:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/6AMwgsWgU7OgmB6XjLQiNEvCnfbwHpeZO+PfD96FIpD6Z/OCaxImfLzz0W2iK5JLXxFU X-Received: by 2002:a0c:ed34:0:b0:66f:bc3f:bd7 with SMTP id u20-20020a0ced34000000b0066fbc3f0bd7mr5290976qvq.27.1700058553554; Wed, 15 Nov 2023 06:29:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700058553; cv=pass; d=google.com; s=arc-20160816; b=a2/NPkWB2tmPCTrlHM4le0mjpqmGcdb++3UO5IP+3vsrgrj19FgQMUD1GMfYTjV6W5 akoVnlQq4q5Bw52JG2uHB5zuIMT7UyHFlsvxYzqcjnPfpHIsi2wKLkQeQKrmjLgVks/Y vED3oiwDlOeqtPcFhQJ17e2CecnLsX4N4pb3Oe7ezrnKN5LBgCt2oQE8/YV+7spQmeO5 a6XiuPqXC8QP9isA3rtyQH+uw0SO+q0ennFL/qyhfwl+bwsau0wMU55fk0+3Gp0C90lU l89i/8fY34zWGzOZE9Nq/ezHiUl4/mroBsfMt7AgavxerRJlLla7KKSof7J/B87oXixl 0BYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:date :user-agent:references:in-reply-to:subject:cc:to:from:ironport-sdr :arc-filter:dmarc-filter:delivered-to; bh=3RnLOFZclda0PeEGnFp9DJKm7lnmmD/IRehH3r9/010=; fh=M+JFvcM5+3taTJfmUkaKH2/IzZ0iGjnUUeA9YwBBmqA=; b=pU8QVUIRHpGLtxqPzAjW9EadJTFZ0CfC/lY2DZ7qaQ/xRGpPwjO3Sk/8f2CB3lgz0z Z+uFi+EJ2wJDRNsngpAE3FAiYBLkljcZYdTgq9HAKpRlt+5NpIeH4prcyTij88CoTmnq pgkgjSaet4LyQkQU4ofARXWkOn/x0t8I1WCS9pz1VAaa9kLE2wRXZmZT0e3xC8WVbLJc 7qalkx+6uk88az5vxxF4Qyhwz6u/LWUL0jEg5q6dtHCUfmxrWVa6Wb6TDDQ11sZdYUEA yybmwe2ASn6Mc1n5OdxERikZY3TeKKCuQTJFqOMnH8uLX2Nkn/EB7JBWW5bf8wYdKAJ3 PJtg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e7-20020ad44187000000b0065b1c33dfcfsi9453080qvp.352.2023.11.15.06.29.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 06:29:13 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 306573858404 for ; Wed, 15 Nov 2023 14:29:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 62AAA3858D37 for ; Wed, 15 Nov 2023 14:28:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 62AAA3858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 62AAA3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.141.98 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700058529; cv=none; b=PlEeSU+W6h81RSQlIrW7ysezVceafxjJh3/dwWT+PHJeLCUXiDysQMhoklujntkmppCgkw0aiGhepF+pHQaxh3uD8gUfJ8kmbbQFkfvbW4Pl7y88tP24hs6ydbvQU4obwxYwIXGK/qZutr76AnSzf7pBzcmYJorke7k+kn89Q8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700058529; c=relaxed/simple; bh=YmpCPitAW/ovY72kDijmZlec0Z7XbLBU9NOfzxc4Gw0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=UEXxzNpR1nlPG62L5JSiqr4UZsXs7YHujlqKtnRlakRgU91NFZ4PoMeAGzoRSXewgswtK9cBPBrqEKBuVK/8705aJYLH7zjovv1NOEDzeiv/1x+Nj9ltnGztWRzffyduqB7NBzWbPnOr5nsktc/Ly76pmblT2XeovVa8nbrlYg4= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: XNo1IIvGTaK69Flhl6YY2A== X-CSE-MsgGUID: NL40z8PjSDCHttMfTQF5wA== X-IronPort-AV: E=Sophos;i="6.03,305,1694764800"; d="scan'208,223";a="25564754" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 15 Nov 2023 06:28:45 -0800 IronPort-SDR: lkLXgFpdpGCuKSvKlAby/oudjDbHlPO6MHe2jbmyBSDEPgOUxWvOpO2sUjdNyPI023hH2kJ2Ut pUFIKeL4i/ubK5OIxdjkomJDEcqtcfzzjUqc7pYBWU8s/LbYUDvIXlm3z8CwNbZG0FGv+++RL4 TXfoPsjAkfIWHWRc3+TfcWEqhsjzni5R2HpesAsF1mKcX1rcT8zLKsI8ntbZZUc1j6Ln5j4+X/ EsEFDzRvHlDCRxxy/3nZSpIVgyQ51Zp+nOKhGUy1Gidq+gj2/aPDuYDUKjUznt2/Gb7O9sTvxr I9k= From: Thomas Schwinge To: Roger Sayle , CC: Tom de Vries Subject: nvptx: Extend 'brev' test cases (was: [PATCH] nvptx: Add suppport for __builtin_nvptx_brev instrinsic) In-Reply-To: <007301d98034$82486ea0$86d94be0$@nextmovesoftware.com> References: <007301d98034$82486ea0$86d94be0$@nextmovesoftware.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/28.2 (x86_64-pc-linux-gnu) Date: Wed, 15 Nov 2023 15:28:36 +0100 Message-ID: <87a5rfum3v.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782640597901921795 X-GMAIL-MSGID: 1782640597901921795 Hi! On 2023-05-06T17:04:57+0100, "Roger Sayle" wrote: > This patch adds support for (a pair of) bit reversal intrinsics > __builtin_nvptx_brev and __builtin_nvptx_brevll which perform 32-bit > and 64-bit bit reversal (using nvptx's brev instruction) matching > the __brev and __brevll instrinsics provided by NVidia's nvcc compiler. > https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH__INTRINSIC__INT.html > > This patch has been tested on nvptx-none which make and make -k check > with no new failures. Ok for mainline? (That got pushed in commit c09471fbc7588db2480f036aa56a2403d3c03ae5 "nvptx: Add suppport for __builtin_nvptx_brev instrinsic".) > --- /dev/null > +++ b/gcc/testsuite/gcc.target/nvptx/brev-1.c > +[...] > --- /dev/null > +++ b/gcc/testsuite/gcc.target/nvptx/brev-2.c > +[...] > --- /dev/null > +++ b/gcc/testsuite/gcc.target/nvptx/brevll-1.c > +[...] > --- /dev/null > +++ b/gcc/testsuite/gcc.target/nvptx/brevll-2.c > +[...] Pushed to master branch commit 61c45c055a5ccfc59463c21ab057dece822d973c "nvptx: Extend 'brev' test cases", see attached. That's in order to observe effects of a later patch, and also to exercise the new nvptx 'check-function-bodies' a bit. Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 From 61c45c055a5ccfc59463c21ab057dece822d973c Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Mon, 4 Sep 2023 23:06:27 +0200 Subject: [PATCH] nvptx: Extend 'brev' test cases In order to observe effects of a later patch, extend the 'brev' test cases added in commit c09471fbc7588db2480f036aa56a2403d3c03ae5 "nvptx: Add suppport for __builtin_nvptx_brev instrinsic". gcc/testsuite/ * gcc.target/nvptx/brev-1.c: Extend. * gcc.target/nvptx/brev-2.c: Rename to... * gcc.target/nvptx/brev-2-O2.c: ... this, and extend. Copy to... * gcc.target/nvptx/brev-2-O0.c: ... this, and adapt for '-O0'. * gcc.target/nvptx/brevll-1.c: Extend. * gcc.target/nvptx/brevll-2.c: Rename to... * gcc.target/nvptx/brevll-2-O2.c: ... this, and extend. Copy to... * gcc.target/nvptx/brevll-2-O0.c: ... this, and adapt for '-O0'. --- gcc/testsuite/gcc.target/nvptx/brev-1.c | 12 +- gcc/testsuite/gcc.target/nvptx/brev-2-O0.c | 129 ++++++++++++ .../nvptx/{brev-2.c => brev-2-O2.c} | 27 +++ gcc/testsuite/gcc.target/nvptx/brevll-1.c | 12 +- gcc/testsuite/gcc.target/nvptx/brevll-2-O0.c | 189 ++++++++++++++++++ .../nvptx/{brevll-2.c => brevll-2-O2.c} | 27 +++ 6 files changed, 392 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/nvptx/brev-2-O0.c rename gcc/testsuite/gcc.target/nvptx/{brev-2.c => brev-2-O2.c} (80%) create mode 100644 gcc/testsuite/gcc.target/nvptx/brevll-2-O0.c rename gcc/testsuite/gcc.target/nvptx/{brevll-2.c => brevll-2-O2.c} (90%) diff --git a/gcc/testsuite/gcc.target/nvptx/brev-1.c b/gcc/testsuite/gcc.target/nvptx/brev-1.c index fbb4fff1e59..af875dd4dcc 100644 --- a/gcc/testsuite/gcc.target/nvptx/brev-1.c +++ b/gcc/testsuite/gcc.target/nvptx/brev-1.c @@ -1,8 +1,16 @@ /* { dg-do compile } */ /* { dg-options "-O2" } */ +/* { dg-final { check-function-bodies {**} {} } } */ + unsigned int foo(unsigned int x) { return __builtin_nvptx_brev(x); } - -/* { dg-final { scan-assembler "brev.b32" } } */ +/* +** foo: +** ... +** mov\.u32 (%r[0-9]+), %ar0; +** brev\.b32 %value, \1; +** st\.param\.u32 \[%value_out\], %value; +** ret; +*/ diff --git a/gcc/testsuite/gcc.target/nvptx/brev-2-O0.c b/gcc/testsuite/gcc.target/nvptx/brev-2-O0.c new file mode 100644 index 00000000000..ca011ebf472 --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/brev-2-O0.c @@ -0,0 +1,129 @@ +/* { dg-do run } */ +/* { dg-options "-O0" } */ +/* { dg-additional-options -save-temps } */ +/* { dg-final { check-function-bodies {**} {} } } */ + +inline __attribute__((always_inline)) +unsigned int bitreverse32(unsigned int x) +{ + return __builtin_nvptx_brev(x); +} + +int main(void) +{ + if (bitreverse32(0x00000000) != 0x00000000) + __builtin_abort(); + if (bitreverse32(0xffffffff) != 0xffffffff) + __builtin_abort(); + + if (bitreverse32(0x00000001) != 0x80000000) + __builtin_abort(); + if (bitreverse32(0x00000002) != 0x40000000) + __builtin_abort(); + if (bitreverse32(0x00000004) != 0x20000000) + __builtin_abort(); + if (bitreverse32(0x00000008) != 0x10000000) + __builtin_abort(); + if (bitreverse32(0x00000010) != 0x08000000) + __builtin_abort(); + if (bitreverse32(0x00000020) != 0x04000000) + __builtin_abort(); + if (bitreverse32(0x00000040) != 0x02000000) + __builtin_abort(); + if (bitreverse32(0x00000080) != 0x01000000) + __builtin_abort(); + if (bitreverse32(0x00000100) != 0x00800000) + __builtin_abort(); + if (bitreverse32(0x00000200) != 0x00400000) + __builtin_abort(); + if (bitreverse32(0x00000400) != 0x00200000) + __builtin_abort(); + if (bitreverse32(0x00000800) != 0x00100000) + __builtin_abort(); + if (bitreverse32(0x00001000) != 0x00080000) + __builtin_abort(); + if (bitreverse32(0x00002000) != 0x00040000) + __builtin_abort(); + if (bitreverse32(0x00004000) != 0x00020000) + __builtin_abort(); + if (bitreverse32(0x00008000) != 0x00010000) + __builtin_abort(); + if (bitreverse32(0x00010000) != 0x00008000) + __builtin_abort(); + if (bitreverse32(0x00020000) != 0x00004000) + __builtin_abort(); + if (bitreverse32(0x00040000) != 0x00002000) + __builtin_abort(); + if (bitreverse32(0x00080000) != 0x00001000) + __builtin_abort(); + if (bitreverse32(0x00100000) != 0x00000800) + __builtin_abort(); + if (bitreverse32(0x00200000) != 0x00000400) + __builtin_abort(); + if (bitreverse32(0x00400000) != 0x00000200) + __builtin_abort(); + if (bitreverse32(0x00800000) != 0x00000100) + __builtin_abort(); + if (bitreverse32(0x01000000) != 0x00000080) + __builtin_abort(); + if (bitreverse32(0x02000000) != 0x00000040) + __builtin_abort(); + if (bitreverse32(0x04000000) != 0x00000020) + __builtin_abort(); + if (bitreverse32(0x08000000) != 0x00000010) + __builtin_abort(); + if (bitreverse32(0x10000000) != 0x00000008) + __builtin_abort(); + if (bitreverse32(0x20000000) != 0x00000004) + __builtin_abort(); + if (bitreverse32(0x40000000) != 0x00000002) + __builtin_abort(); + if (bitreverse32(0x80000000) != 0x00000001) + __builtin_abort(); + + if (bitreverse32(0x01234567) != 0xe6a2c480) + __builtin_abort(); + if (bitreverse32(0xe6a2c480) != 0x01234567) + __builtin_abort(); + if (bitreverse32(0xdeadbeef) != 0xf77db57b) + __builtin_abort(); + if (bitreverse32(0xf77db57b) != 0xdeadbeef) + __builtin_abort(); + if (bitreverse32(0xcafebabe) != 0x7d5d7f53) + __builtin_abort(); + if (bitreverse32(0x7d5d7f53) != 0xcafebabe) + __builtin_abort(); + + return 0; +} +/* +** main: +** ... +** mov\.u32 (%r[0-9]+), 0; +** st\.u32 (\[%frame[+0-9]*\]), \1; +** ld\.u32 (%r[0-9]+), \2; +** brev\.b32 (%r[0-9]+), \3; +** setp\.[^.]+\.u32 %r[0-9]+, \4, 0; +** ... +** mov\.u32 (%r[0-9]+), -1; +** st\.u32 (\[%frame[+0-9]*\]), \5; +** ld\.u32 (%r[0-9]+), \6; +** brev\.b32 (%r[0-9]+), \7; +** setp\.[^.]+\.u32 %r[0-9]+, \8, -1; +** ... +** mov\.u32 (%r[0-9]+), 1; +** st\.u32 (\[%frame[+0-9]*\]), \9; +** ld\.u32 (%r[0-9]+), \10; +** brev\.b32 (%r[0-9]+), \11; +** setp\.[^.]+\.u32 %r[0-9]+, \12, -2147483648; +** ... +** mov\.u32 (%r[0-9]+), 2; +** st\.u32 (\[%frame[+0-9]*\]), \13; +** ld\.u32 (%r[0-9]+), \14; +** brev\.b32 (%r[0-9]+), \15; +** setp\.[^.]+\.u32 %r[0-9]+, \16, 1073741824; +** ... +*/ + +/* { dg-final { scan-assembler-times {\tbrev\.b32\t} 40 } } */ +/* { dg-final { scan-assembler {\mabort\M} } } */ diff --git a/gcc/testsuite/gcc.target/nvptx/brev-2.c b/gcc/testsuite/gcc.target/nvptx/brev-2-O2.c similarity index 80% rename from gcc/testsuite/gcc.target/nvptx/brev-2.c rename to gcc/testsuite/gcc.target/nvptx/brev-2-O2.c index 9d0defe80bb..e35052208d0 100644 --- a/gcc/testsuite/gcc.target/nvptx/brev-2.c +++ b/gcc/testsuite/gcc.target/nvptx/brev-2-O2.c @@ -1,5 +1,9 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ +/* { dg-additional-options -save-temps } */ +/* { dg-final { check-function-bodies {**} {} } } */ + +inline __attribute__((always_inline)) unsigned int bitreverse32(unsigned int x) { return __builtin_nvptx_brev(x); @@ -89,6 +93,29 @@ int main(void) __builtin_abort(); if (bitreverse32(0x7d5d7f53) != 0xcafebabe) __builtin_abort(); + return 0; } +/* +** main: +** ... +** mov\.u32 (%r[0-9]+), 0; +** brev\.b32 (%r[0-9]+), \1; +** setp\.[^.]+\.u32 %r[0-9]+, \2, 0; +** ... +** mov\.u32 (%r[0-9]+), -1; +** brev\.b32 (%r[0-9]+), \3; +** setp\.[^.]+\.u32 %r[0-9]+, \4, -1; +** ... +** mov\.u32 (%r[0-9]+), 1; +** brev\.b32 (%r[0-9]+), \5; +** setp\.[^.]+\.u32 %r[0-9]+, \6, -2147483648; +** ... +** mov\.u32 (%r[0-9]+), 2; +** brev\.b32 (%r[0-9]+), \7; +** setp\.[^.]+\.u32 %r[0-9]+, \8, 1073741824; +** ... +*/ +/* { dg-final { scan-assembler-times {\tbrev\.b32\t} 40 } } */ +/* { dg-final { scan-assembler {\mabort\M} } } */ diff --git a/gcc/testsuite/gcc.target/nvptx/brevll-1.c b/gcc/testsuite/gcc.target/nvptx/brevll-1.c index 7009d5f5f8c..0b03fee9292 100644 --- a/gcc/testsuite/gcc.target/nvptx/brevll-1.c +++ b/gcc/testsuite/gcc.target/nvptx/brevll-1.c @@ -1,8 +1,16 @@ /* { dg-do compile } */ /* { dg-options "-O2" } */ +/* { dg-final { check-function-bodies {**} {} } } */ + unsigned long foo(unsigned long x) { return __builtin_nvptx_brevll(x); } - -/* { dg-final { scan-assembler "brev.b64" } } */ +/* +** foo: +** ... +** mov\.u64 (%r[0-9]+), %ar0; +** brev\.b64 %value, \1; +** st\.param\.u64 \[%value_out\], %value; +** ret; +*/ diff --git a/gcc/testsuite/gcc.target/nvptx/brevll-2-O0.c b/gcc/testsuite/gcc.target/nvptx/brevll-2-O0.c new file mode 100644 index 00000000000..32bbfbf7ad6 --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/brevll-2-O0.c @@ -0,0 +1,189 @@ +/* { dg-do run } */ +/* { dg-options "-O0" } */ +/* { dg-additional-options -save-temps } */ +/* { dg-final { check-function-bodies {**} {} } } */ + +inline __attribute__((always_inline)) +unsigned long long bitreverse64(unsigned long long x) +{ + return __builtin_nvptx_brevll(x); +} + +int main(void) +{ + if (bitreverse64(0x0000000000000000ll) != 0x0000000000000000ll) + __builtin_abort(); + if (bitreverse64(0xffffffffffffffffll) != 0xffffffffffffffffll) + __builtin_abort(); + + if (bitreverse64(0x0000000000000001ll) != 0x8000000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000000002ll) != 0x4000000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000000004ll) != 0x2000000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000000008ll) != 0x1000000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000000010ll) != 0x0800000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000000020ll) != 0x0400000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000000040ll) != 0x0200000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000000080ll) != 0x0100000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000000100ll) != 0x0080000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000000200ll) != 0x0040000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000000400ll) != 0x0020000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000000800ll) != 0x0010000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000001000ll) != 0x0008000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000002000ll) != 0x0004000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000004000ll) != 0x0002000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000008000ll) != 0x0001000000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000010000ll) != 0x0000800000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000020000ll) != 0x0000400000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000040000ll) != 0x0000200000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000080000ll) != 0x0000100000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000100000ll) != 0x0000080000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000200000ll) != 0x0000040000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000400000ll) != 0x0000020000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000000800000ll) != 0x0000010000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000001000000ll) != 0x0000008000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000002000000ll) != 0x0000004000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000004000000ll) != 0x0000002000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000008000000ll) != 0x0000001000000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000010000000ll) != 0x0000000800000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000020000000ll) != 0x0000000400000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000040000000ll) != 0x0000000200000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000080000000ll) != 0x0000000100000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000100000000ll) != 0x0000000080000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000200000000ll) != 0x0000000040000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000400000000ll) != 0x0000000020000000ll) + __builtin_abort(); + if (bitreverse64(0x0000000800000000ll) != 0x0000000010000000ll) + __builtin_abort(); + if (bitreverse64(0x0000001000000000ll) != 0x0000000008000000ll) + __builtin_abort(); + if (bitreverse64(0x0000002000000000ll) != 0x0000000004000000ll) + __builtin_abort(); + if (bitreverse64(0x0000004000000000ll) != 0x0000000002000000ll) + __builtin_abort(); + if (bitreverse64(0x0000008000000000ll) != 0x0000000001000000ll) + __builtin_abort(); + if (bitreverse64(0x0000010000000000ll) != 0x0000000000800000ll) + __builtin_abort(); + if (bitreverse64(0x0000020000000000ll) != 0x0000000000400000ll) + __builtin_abort(); + if (bitreverse64(0x0000040000000000ll) != 0x0000000000200000ll) + __builtin_abort(); + if (bitreverse64(0x0000080000000000ll) != 0x0000000000100000ll) + __builtin_abort(); + if (bitreverse64(0x0000100000000000ll) != 0x0000000000080000ll) + __builtin_abort(); + if (bitreverse64(0x0000200000000000ll) != 0x0000000000040000ll) + __builtin_abort(); + if (bitreverse64(0x0000400000000000ll) != 0x0000000000020000ll) + __builtin_abort(); + if (bitreverse64(0x0000800000000000ll) != 0x0000000000010000ll) + __builtin_abort(); + if (bitreverse64(0x0001000000000000ll) != 0x0000000000008000ll) + __builtin_abort(); + if (bitreverse64(0x0002000000000000ll) != 0x0000000000004000ll) + __builtin_abort(); + if (bitreverse64(0x0004000000000000ll) != 0x0000000000002000ll) + __builtin_abort(); + if (bitreverse64(0x0008000000000000ll) != 0x0000000000001000ll) + __builtin_abort(); + if (bitreverse64(0x0010000000000000ll) != 0x0000000000000800ll) + __builtin_abort(); + if (bitreverse64(0x0020000000000000ll) != 0x0000000000000400ll) + __builtin_abort(); + if (bitreverse64(0x0040000000000000ll) != 0x0000000000000200ll) + __builtin_abort(); + if (bitreverse64(0x0080000000000000ll) != 0x0000000000000100ll) + __builtin_abort(); + if (bitreverse64(0x0100000000000000ll) != 0x0000000000000080ll) + __builtin_abort(); + if (bitreverse64(0x0200000000000000ll) != 0x0000000000000040ll) + __builtin_abort(); + if (bitreverse64(0x0400000000000000ll) != 0x0000000000000020ll) + __builtin_abort(); + if (bitreverse64(0x0800000000000000ll) != 0x0000000000000010ll) + __builtin_abort(); + if (bitreverse64(0x1000000000000000ll) != 0x0000000000000008ll) + __builtin_abort(); + if (bitreverse64(0x2000000000000000ll) != 0x0000000000000004ll) + __builtin_abort(); + if (bitreverse64(0x4000000000000000ll) != 0x0000000000000002ll) + __builtin_abort(); + if (bitreverse64(0x8000000000000000ll) != 0x0000000000000001ll) + __builtin_abort(); + + if (bitreverse64(0x0123456789abcdefll) != 0xf7b3d591e6a2c480ll) + __builtin_abort(); + if (bitreverse64(0xf7b3d591e6a2c480ll) != 0x0123456789abcdefll) + __builtin_abort(); + if (bitreverse64(0xdeadbeefcafebabell) != 0x7d5d7f53f77db57bll) + __builtin_abort(); + if (bitreverse64(0x7d5d7f53f77db57bll) != 0xdeadbeefcafebabell) + __builtin_abort(); + + return 0; +} +/* +** main: +** ... +** mov\.u64 (%r[0-9]+), 0; +** st\.u64 (\[%frame[+0-9]*\]), \1; +** ld\.u64 (%r[0-9]+), \2; +** brev\.b64 (%r[0-9]+), \3; +** setp\.[^.]+\.u64 %r[0-9]+, \4, 0; +** ... +** mov\.u64 (%r[0-9]+), -1; +** st\.u64 (\[%frame[+0-9]*\]), \5; +** ld\.u64 (%r[0-9]+), \6; +** brev\.b64 (%r[0-9]+), \7; +** setp\.[^.]+\.u64 %r[0-9]+, \8, -1; +** ... +** mov\.u64 (%r[0-9]+), 1; +** st\.u64 (\[%frame[+0-9]*\]), \9; +** ld\.u64 (%r[0-9]+), \10; +** brev\.b64 (%r[0-9]+), \11; +** setp\.[^.]+\.u64 %r[0-9]+, \12, -9223372036854775808; +** ... +** mov\.u64 (%r[0-9]+), 2; +** st\.u64 (\[%frame[+0-9]*\]), \13; +** ld\.u64 (%r[0-9]+), \14; +** brev\.b64 (%r[0-9]+), \15; +** setp\.[^.]+\.u64 %r[0-9]+, \16, 4611686018427387904; +** ... +*/ + +/* { dg-final { scan-assembler-times {\tbrev\.b64\t} 70 } } */ +/* { dg-final { scan-assembler {\mabort\M} } } */ diff --git a/gcc/testsuite/gcc.target/nvptx/brevll-2.c b/gcc/testsuite/gcc.target/nvptx/brevll-2-O2.c similarity index 90% rename from gcc/testsuite/gcc.target/nvptx/brevll-2.c rename to gcc/testsuite/gcc.target/nvptx/brevll-2-O2.c index 56054b1e92a..cbfda1b9601 100644 --- a/gcc/testsuite/gcc.target/nvptx/brevll-2.c +++ b/gcc/testsuite/gcc.target/nvptx/brevll-2-O2.c @@ -1,5 +1,9 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ +/* { dg-additional-options -save-temps } */ +/* { dg-final { check-function-bodies {**} {} } } */ + +inline __attribute__((always_inline)) unsigned long long bitreverse64(unsigned long long x) { return __builtin_nvptx_brevll(x); @@ -149,6 +153,29 @@ int main(void) __builtin_abort(); if (bitreverse64(0x7d5d7f53f77db57bll) != 0xdeadbeefcafebabell) __builtin_abort(); + return 0; } +/* +** main: +** ... +** mov\.u64 (%r[0-9]+), 0; +** brev\.b64 (%r[0-9]+), \1; +** setp\.[^.]+\.u64 %r[0-9]+, \2, 0; +** ... +** mov\.u64 (%r[0-9]+), -1; +** brev\.b64 (%r[0-9]+), \3; +** setp\.[^.]+\.u64 %r[0-9]+, \4, -1; +** ... +** mov\.u64 (%r[0-9]+), 1; +** brev\.b64 (%r[0-9]+), \5; +** setp\.[^.]+\.u64 %r[0-9]+, \6, -9223372036854775808; +** ... +** mov\.u64 (%r[0-9]+), 2; +** brev\.b64 (%r[0-9]+), \7; +** setp\.[^.]+\.u64 %r[0-9]+, \8, 4611686018427387904; +** ... +*/ +/* { dg-final { scan-assembler-times {\tbrev\.b64\t} 70 } } */ +/* { dg-final { scan-assembler {\mabort\M} } } */ -- 2.34.1