Testcase for old PR 47059

Message ID ri6pn2f1fes.fsf@suse.cz
State New
Headers show
Series
  • Testcase for old PR 47059
Related show

Commit Message

Martin Jambor Jan. 8, 2021, 5:56 p.m.
Hi,

I stumbled across PR 47059 from 2010 which has been addressed by
store-merging.  I am going to close it but would like to add its
testcase too.

OK for trunk?

Thanks,

Martin


gcc/testsuite/ChangeLog:

2021-01-08  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/47059
	* gcc.dg/tree-ssa/pr47059.c: New test.
---
 gcc/testsuite/gcc.dg/tree-ssa/pr47059.c | 45 +++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr47059.c

-- 
2.29.2

Patch

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr47059.c b/gcc/testsuite/gcc.dg/tree-ssa/pr47059.c
new file mode 100644
index 00000000000..9f9c61aa213
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr47059.c
@@ -0,0 +1,45 @@ 
+/* { dg-do compile } */
+/* { dg-options "-Os -fdump-tree-optimized" } */
+
+
+struct struct1
+{
+  void *data;
+  unsigned short f1;
+  unsigned short f2;
+};
+typedef struct struct1 S1;
+
+struct struct2
+{
+  int f3;
+  S1 f4;
+};
+typedef struct struct2 S2;
+
+
+extern void foo (S1 *ptr);
+extern S2 gstruct2_var;
+extern S1 gstruct1_var;
+
+static inline S1 bar (const S1 *ptr) __attribute__ ((always_inline));
+
+static inline S1
+bar (const S1 *ptr)
+{
+  S1 ls_var = *ptr;
+  foo (&ls_var);
+  return ls_var;
+}
+
+int
+main ()
+{
+  S2 *ps_var;
+
+  ps_var = &gstruct2_var;
+  ps_var->f4 = bar (&gstruct1_var);
+
+  return 0;
+}
+/* { dg-final { scan-tree-dump-times "short unsigned int\[^*\]*;" 0 "optimized"} } */