From: Martin Jambor Date: Fri, 22 Jan 2021 17:09:38 +0000 (+0100) Subject: Testcase for old PR 47059 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d7e681fc3afff24a6279058cbb0b0dc4cd96be8c;p=gcc.git Testcase for old PR 47059 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. gcc/testsuite/ChangeLog: 2021-01-08 Martin Jambor PR tree-optimization/47059 * gcc.dg/tree-ssa/pr47059.c: New test. --- 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"} } */