From 39e1ec22dbaad6cf8e3dc16fd4a576d03215201e Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tschwinge@baylibre.com>
Date: Wed, 26 Feb 2025 17:17:44 +0100
Subject: [PATCH] Add 'gcc.target/nvptx/stack_frame-1.c'

	gcc/testsuite/
	* gcc.target/nvptx/stack_frame-1.c: New.
---
 .../gcc.target/nvptx/stack_frame-1.c          | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/nvptx/stack_frame-1.c

diff --git a/gcc/testsuite/gcc.target/nvptx/stack_frame-1.c b/gcc/testsuite/gcc.target/nvptx/stack_frame-1.c
new file mode 100644
index 000000000000..476d0ac93ed0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/stack_frame-1.c
@@ -0,0 +1,34 @@
+/* GCC emits an unused stack frame.  */
+
+/* { dg-do assemble } */
+/* { dg-options {-O2 -mno-soft-stack} } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { check-function-bodies {** } {} } } */
+
+/* Greatly reduced from libgcc code, where this issue is visible for
+   '_divdi3.o:__divti3', '_divmoddi4.o:__divmodti4', '_moddi3.o:__modti3',
+   '_udivdi3.o:__udivti3', '_udivmoddi4.o:__udivmodti4',
+   '_umoddi3.o:__umodti3'.  */
+
+int f (int n)
+{
+  const union {
+    struct { long low, high; };
+    __int128 ll;
+  } ww = {{.low = n, .high = 0}};
+  return (int) ww.ll;
+}
+/*
+** f:
+** \.visible \.func \(\.param\.u32 %value_out\) f \(\.param\.u32 %in_ar0\)
+** {
+** 	\.reg\.u32 %value;
+** 	\.reg\.u32 %ar0;
+** 	ld\.param\.u32 %ar0, \[%in_ar0\];
+** 	\.local \.align 16 \.b8 %frame_ar\[16\];
+** 	\.reg\.u64 %frame;
+** 	cvta\.local\.u64 %frame, %frame_ar;
+** 		mov\.u32	%value, %ar0;
+** 	st\.param\.u32	\[%value_out\], %value;
+** 	ret;
+*/
-- 
GitLab