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  <mjambor@suse.cz>

	PR tree-optimization/47059
	* gcc.dg/tree-ssa/pr47059.c: New test.
This commit is contained in:
Martin Jambor 2021-01-22 18:09:38 +01:00
parent 9d33785f57
commit d7e681fc3a

View File

@ -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"} } */