aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-36.c
blob: 23a53bb4ad2fb909d9911991e97e574297aaf4fd (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* { dg-options "-O2 -fdump-tree-dse-details -fno-tree-fre" } */
#include <string.h>
#include <stdlib.h>

struct X
{
  char mem0[10];
  char mem1[10];
};


void blah (struct X);


void
foo1()
{
  struct X x = { };
  memset (x.mem1, 0, sizeof x.mem1);
  blah (x);
}

void
foo2()
{
  struct X x = { };
  x.mem1[5] = 0;
  blah (x);
}

void
bar1 ()
{
  struct X x;
  memset (&x, 0, sizeof x);
  memset (&x.mem1, 0, sizeof x.mem1);
  blah (x);
}
void
bar2 ()
{
  struct X x;
  memset (&x, 0, sizeof x);
  x.mem1[5] = 0;
  blah (x);
}

void
baz1 ()
{
  struct X *x = calloc (sizeof (struct X), 1);
  memset (&x->mem1, 0, sizeof x->mem1);
  blah (*x);
}

void
baz2 ()
{
  struct X *x = calloc (sizeof (struct X), 1);
  x->mem1[5] = 0;
  blah (*x);
}
/* { dg-final { scan-tree-dump-times "Deleted redundant call" 3 "dse1" } } */
/* { dg-final { scan-tree-dump-times "Deleted redundant store" 3 "dse1" } } */