aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/nrv3.c
blob: c28b8ec570dc72a20d8b9860afa697187fe7101d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* Verify that gimple-level NRV is occurring when values other than the
   return slot are call-clobbered.  */
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */

#ifdef __SPU__
/* SPU returns aggregates up to 1172 bytes in registers.  */
typedef struct { int x[300]; void *y; } S;
#else
typedef struct { int x[20]; void *y; } S;
#endif
typedef struct { int a; S b; } T;
S nrv_candidate (void);
void use_result (S, int);
int *ptr;
void foo (void)
{
  S result;
  T result_arr[10][5];

  int i;

  ptr = &i;

  /* i is call-clobbered for these calls, but result and result_arr
     aren't.  */
  result = nrv_candidate ();
  result_arr[3][4].b = nrv_candidate ();

  use_result (result, i);
  use_result (result_arr[3][4].b, i);
}

/* { dg-final { scan-tree-dump-times "return slot optimization" 2 "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */