aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <tschwinge@baylibre.com>2025-02-24 22:03:47 +0100
committerThomas Schwinge <tschwinge@baylibre.com>2025-02-27 21:48:15 +0100
commit5c9ef3bdab0c4377c8ba90c234ce891b80ae6338 (patch)
treec4c2419c0fa59a51c39948b839449a9c30177adb
parentcfc9f42122f41668b986126ba7e65e3dd8bf1e9e (diff)
downloadgcc-5c9ef3bdab0c4377c8ba90c234ce891b80ae6338.zip
gcc-5c9ef3bdab0c4377c8ba90c234ce891b80ae6338.tar.gz
gcc-5c9ef3bdab0c4377c8ba90c234ce891b80ae6338.tar.bz2
nvptx: Add test cases for dead/unused 'alloca'/VLA
gcc/testsuite/ * gcc.target/nvptx/alloca-1-dead-O0-sm_30.c: New. * gcc.target/nvptx/alloca-1-dead-O0.c: Likewise. * gcc.target/nvptx/alloca-1-dead-O1-sm_30.c: Likewise. * gcc.target/nvptx/alloca-1-dead-O1.c: Likewise. * gcc.target/nvptx/alloca-1-unused-O0-sm_30.c: Likewise. * gcc.target/nvptx/alloca-1-unused-O0.c: Likewise. * gcc.target/nvptx/alloca-1-unused-O1-sm_30.c: Likewise. * gcc.target/nvptx/alloca-1-unused-O1.c: Likewise. * gcc.target/nvptx/vla-1-dead-O0-sm_30.c: Likewise. * gcc.target/nvptx/vla-1-dead-O0.c: Likewise. * gcc.target/nvptx/vla-1-dead-O1-sm_30.c: Likewise. * gcc.target/nvptx/vla-1-dead-O1.c: Likewise. * gcc.target/nvptx/vla-1-unused-O0-sm_30.c: Likewise. * gcc.target/nvptx/vla-1-unused-O0.c: Likewise. * gcc.target/nvptx/vla-1-unused-O1-sm_30.c: Likewise. * gcc.target/nvptx/vla-1-unused-O1.c: Likewise.
-rw-r--r--gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O0-sm_30.c10
-rw-r--r--gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O0.c48
-rw-r--r--gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O1-sm_30.c17
-rw-r--r--gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O1.c17
-rw-r--r--gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O0-sm_30.c9
-rw-r--r--gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O0.c16
-rw-r--r--gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O1-sm_30.c16
-rw-r--r--gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O1.c16
-rw-r--r--gcc/testsuite/gcc.target/nvptx/vla-1-dead-O0-sm_30.c10
-rw-r--r--gcc/testsuite/gcc.target/nvptx/vla-1-dead-O0.c27
-rw-r--r--gcc/testsuite/gcc.target/nvptx/vla-1-dead-O1-sm_30.c19
-rw-r--r--gcc/testsuite/gcc.target/nvptx/vla-1-dead-O1.c19
-rw-r--r--gcc/testsuite/gcc.target/nvptx/vla-1-unused-O0-sm_30.c9
-rw-r--r--gcc/testsuite/gcc.target/nvptx/vla-1-unused-O0.c26
-rw-r--r--gcc/testsuite/gcc.target/nvptx/vla-1-unused-O1-sm_30.c18
-rw-r--r--gcc/testsuite/gcc.target/nvptx/vla-1-unused-O1.c18
16 files changed, 295 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O0-sm_30.c b/gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O0-sm_30.c
new file mode 100644
index 0000000..2d002b5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O0-sm_30.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options {-O0 -mno-soft-stack} } */
+/* { dg-additional-options -march=sm_30 } */
+
+void f(void)
+{
+ char *a = __builtin_alloca(123);
+ /* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */
+ a[0] = 0;
+}
diff --git a/gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O0.c b/gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O0.c
new file mode 100644
index 0000000..ecc47e0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O0.c
@@ -0,0 +1,48 @@
+/* { dg-do assemble } */
+/* { dg-options {-O0 -mno-soft-stack} } */
+/* { dg-add-options nvptx_alloca_ptx } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {** } {} } } */
+
+void f(void)
+{
+ char *a = __builtin_alloca(123);
+ a[0] = 0;
+}
+/*
+** f:
+** \.visible \.func f
+** {
+** \.local \.align 16 \.b8 %frame_ar\[16\];
+** \.reg\.u64 %frame;
+** cvta\.local\.u64 %frame, %frame_ar;
+** \.reg\.u64 (%r[0-9]+);
+** \.reg\.u64 (%r[0-9]+);
+** \.reg\.u64 (%r[0-9]+);
+** \.reg\.u64 (%r[0-9]+);
+** \.reg\.u64 (%r[0-9]+);
+** \.reg\.u64 (%r[0-9]+);
+** \.reg\.u64 (%r[0-9]+);
+** \.reg\.u64 (%r[0-9]+);
+** \.reg\.u64 (%r[0-9]+);
+** \.reg\.u32 (%r[0-9]+);
+** \.reg\.u64 (%r[0-9]+);
+** mov\.u64 \11, 16;
+** add\.u64 \1, \11, -1;
+** add\.u64 \2, \1, 123;
+** div\.u64 \3, \2, 16;
+** mul\.lo\.u64 \4, \3, 16;
+** {
+** \.reg\.u64 \5_local;
+** alloca\.u64 \5_local, \4;
+** cvta\.local\.u64 \5, \5_local;
+** }
+** add\.u64 \6, \5, 15;
+** shr\.u64 \7, \6, 4;
+** shl\.b64 \8, \7, 4;
+** st\.u64 \[%frame\], \8;
+** ld\.u64 \9, \[%frame\];
+** mov\.u32 \10, 0;
+** st\.u8 \[\9\], \10;
+** ret;
+*/
diff --git a/gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O1-sm_30.c b/gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O1-sm_30.c
new file mode 100644
index 0000000..e296c04
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O1-sm_30.c
@@ -0,0 +1,17 @@
+/* { dg-do assemble } */
+/* { dg-options {-O1 -mno-soft-stack} } */
+/* { dg-additional-options -march=sm_30 } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {** } {} } } */
+
+void f(void)
+{
+ char *a = __builtin_alloca(123);
+ a[0] = 0;
+}
+/*
+** f:
+** \.visible \.func f
+** {
+** ret;
+*/
diff --git a/gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O1.c b/gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O1.c
new file mode 100644
index 0000000..5a1a573
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/alloca-1-dead-O1.c
@@ -0,0 +1,17 @@
+/* { dg-do assemble } */
+/* { dg-options {-O1 -mno-soft-stack} } */
+/* { dg-add-options nvptx_alloca_ptx } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {** } {} } } */
+
+void f(void)
+{
+ char *a = __builtin_alloca(123);
+ a[0] = 0;
+}
+/*
+** f:
+** \.visible \.func f
+** {
+** ret;
+*/
diff --git a/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O0-sm_30.c b/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O0-sm_30.c
new file mode 100644
index 0000000..c948ccc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O0-sm_30.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options {-O0 -mno-soft-stack} } */
+/* { dg-additional-options -march=sm_30 } */
+
+void f(void)
+{
+ __builtin_alloca(123); /* { dg-warning "ignoring return value of '__builtin_alloca' declared with attribute 'warn_unused_result'" } */
+ /* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */
+}
diff --git a/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O0.c b/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O0.c
new file mode 100644
index 0000000..fbd147d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O0.c
@@ -0,0 +1,16 @@
+/* { dg-do assemble } */
+/* { dg-options {-O0 -mno-soft-stack} } */
+/* { dg-add-options nvptx_alloca_ptx } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {** } {} } } */
+
+void f(void)
+{
+ __builtin_alloca(123); /* { dg-warning "ignoring return value of '__builtin_alloca' declared with attribute 'warn_unused_result'" } */
+}
+/*
+** f:
+** \.visible \.func f
+** {
+** ret;
+*/
diff --git a/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O1-sm_30.c b/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O1-sm_30.c
new file mode 100644
index 0000000..fb12d09
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O1-sm_30.c
@@ -0,0 +1,16 @@
+/* { dg-do assemble } */
+/* { dg-options {-O1 -mno-soft-stack} } */
+/* { dg-additional-options -march=sm_30 } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {** } {} } } */
+
+void f(void)
+{
+ __builtin_alloca(123); /* { dg-warning "ignoring return value of '__builtin_alloca' declared with attribute 'warn_unused_result'" } */
+}
+/*
+** f:
+** \.visible \.func f
+** {
+** ret;
+*/
diff --git a/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O1.c b/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O1.c
new file mode 100644
index 0000000..69b8a68
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O1.c
@@ -0,0 +1,16 @@
+/* { dg-do assemble } */
+/* { dg-options {-O1 -mno-soft-stack} } */
+/* { dg-add-options nvptx_alloca_ptx } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {** } {} } } */
+
+void f(void)
+{
+ __builtin_alloca(123); /* { dg-warning "ignoring return value of '__builtin_alloca' declared with attribute 'warn_unused_result'" } */
+}
+/*
+** f:
+** \.visible \.func f
+** {
+** ret;
+*/
diff --git a/gcc/testsuite/gcc.target/nvptx/vla-1-dead-O0-sm_30.c b/gcc/testsuite/gcc.target/nvptx/vla-1-dead-O0-sm_30.c
new file mode 100644
index 0000000..0433035
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/vla-1-dead-O0-sm_30.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options {-O0 -mno-soft-stack} } */
+/* { dg-additional-options -march=sm_30 } */
+
+void f(int s)
+{
+ char a[s];
+ /* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */
+ a[0] = 0;
+}
diff --git a/gcc/testsuite/gcc.target/nvptx/vla-1-dead-O0.c b/gcc/testsuite/gcc.target/nvptx/vla-1-dead-O0.c
new file mode 100644
index 0000000..76d35c7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/vla-1-dead-O0.c
@@ -0,0 +1,27 @@
+/* { dg-do assemble } */
+/* { dg-options {-O0 -mno-soft-stack} } */
+/* { dg-add-options nvptx_alloca_ptx } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {**} {} } } */
+
+void f(int s)
+{
+ char a[s];
+ a[0] = 0;
+}
+/*
+** f:
+** ...
+** cvt\.s64\.s32 (%r[0-9]+), (%r[0-9]+);
+** mov\.u64 (%r[0-9]+), 16;
+** add\.u64 (%r[0-9]+), \3, -1;
+** add\.u64 (%r[0-9]+), \1, \4;
+** div\.u64 (%r[0-9]+), \5, 16;
+** mul\.lo\.u64 (%r[0-9]+), \6, 16;
+** {
+** \.reg\.u64 (%r[0-9]+)_local;
+** alloca\.u64 \8_local, \7;
+** cvta\.local\.u64 \8, \8_local;
+** }
+** ...
+*/
diff --git a/gcc/testsuite/gcc.target/nvptx/vla-1-dead-O1-sm_30.c b/gcc/testsuite/gcc.target/nvptx/vla-1-dead-O1-sm_30.c
new file mode 100644
index 0000000..18e2195
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/vla-1-dead-O1-sm_30.c
@@ -0,0 +1,19 @@
+/* { dg-do assemble } */
+/* { dg-options {-O1 -mno-soft-stack} } */
+/* { dg-additional-options -march=sm_30 } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {** } {} } } */
+
+void f(int s)
+{
+ char a[s];
+ a[0] = 0;
+}
+/*
+** f:
+** \.visible \.func f \(\.param\.u32 %in_ar0\)
+** {
+** \.reg\.u32 %ar0;
+** ld\.param\.u32 %ar0, \[%in_ar0\];
+** ret;
+*/
diff --git a/gcc/testsuite/gcc.target/nvptx/vla-1-dead-O1.c b/gcc/testsuite/gcc.target/nvptx/vla-1-dead-O1.c
new file mode 100644
index 0000000..12d2cba
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/vla-1-dead-O1.c
@@ -0,0 +1,19 @@
+/* { dg-do assemble } */
+/* { dg-options {-O1 -mno-soft-stack} } */
+/* { dg-add-options nvptx_alloca_ptx } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {** } {} } } */
+
+void f(int s)
+{
+ char a[s];
+ a[0] = 0;
+}
+/*
+** f:
+** \.visible \.func f \(\.param\.u32 %in_ar0\)
+** {
+** \.reg\.u32 %ar0;
+** ld\.param\.u32 %ar0, \[%in_ar0\];
+** ret;
+*/
diff --git a/gcc/testsuite/gcc.target/nvptx/vla-1-unused-O0-sm_30.c b/gcc/testsuite/gcc.target/nvptx/vla-1-unused-O0-sm_30.c
new file mode 100644
index 0000000..e540f29
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/vla-1-unused-O0-sm_30.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options {-O0 -mno-soft-stack} } */
+/* { dg-additional-options -march=sm_30 } */
+
+void f(int s)
+{
+ char a[s];
+ /* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */
+}
diff --git a/gcc/testsuite/gcc.target/nvptx/vla-1-unused-O0.c b/gcc/testsuite/gcc.target/nvptx/vla-1-unused-O0.c
new file mode 100644
index 0000000..00ac8ca
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/vla-1-unused-O0.c
@@ -0,0 +1,26 @@
+/* { dg-do assemble } */
+/* { dg-options {-O0 -mno-soft-stack} } */
+/* { dg-add-options nvptx_alloca_ptx } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {**} {} } } */
+
+void f(int s)
+{
+ char a[s];
+}
+/*
+** f:
+** ...
+** cvt\.s64\.s32 (%r[0-9]+), (%r[0-9]+);
+** mov\.u64 (%r[0-9]+), 16;
+** add\.u64 (%r[0-9]+), \3, -1;
+** add\.u64 (%r[0-9]+), \1, \4;
+** div\.u64 (%r[0-9]+), \5, 16;
+** mul\.lo\.u64 (%r[0-9]+), \6, 16;
+** {
+** \.reg\.u64 (%r[0-9]+)_local;
+** alloca\.u64 \8_local, \7;
+** cvta\.local\.u64 \8, \8_local;
+** }
+** ...
+*/
diff --git a/gcc/testsuite/gcc.target/nvptx/vla-1-unused-O1-sm_30.c b/gcc/testsuite/gcc.target/nvptx/vla-1-unused-O1-sm_30.c
new file mode 100644
index 0000000..394da48
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/vla-1-unused-O1-sm_30.c
@@ -0,0 +1,18 @@
+/* { dg-do assemble } */
+/* { dg-options {-O1 -mno-soft-stack} } */
+/* { dg-additional-options -march=sm_30 } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {** } {} } } */
+
+void f(int s)
+{
+ char a[s];
+}
+/*
+** f:
+** \.visible \.func f \(\.param\.u32 %in_ar0\)
+** {
+** \.reg\.u32 %ar0;
+** ld\.param\.u32 %ar0, \[%in_ar0\];
+** ret;
+*/
diff --git a/gcc/testsuite/gcc.target/nvptx/vla-1-unused-O1.c b/gcc/testsuite/gcc.target/nvptx/vla-1-unused-O1.c
new file mode 100644
index 0000000..060da28
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/vla-1-unused-O1.c
@@ -0,0 +1,18 @@
+/* { dg-do assemble } */
+/* { dg-options {-O1 -mno-soft-stack} } */
+/* { dg-add-options nvptx_alloca_ptx } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {** } {} } } */
+
+void f(int s)
+{
+ char a[s];
+}
+/*
+** f:
+** \.visible \.func f \(\.param\.u32 %in_ar0\)
+** {
+** \.reg\.u32 %ar0;
+** ld\.param\.u32 %ar0, \[%in_ar0\];
+** ret;
+*/