nvptx: Extend 'brev' test cases (was: [PATCH] nvptx: Add suppport for __builtin_nvptx_brev instrinsic)

Message ID 87a5rfum3v.fsf@euler.schwinge.homeip.net
State Unresolved
Headers
Series nvptx: Extend 'brev' test cases (was: [PATCH] nvptx: Add suppport for __builtin_nvptx_brev instrinsic) |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Thomas Schwinge Nov. 15, 2023, 2:28 p.m. UTC
  Hi!

On 2023-05-06T17:04:57+0100, "Roger Sayle" <roger@nextmovesoftware.com> 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
  

Patch

From 61c45c055a5ccfc59463c21ab057dece822d973c Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
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