1  /* { dg-options "-O2 -fdump-tree-dse-details -fno-tree-fre" } */
       2  #include <string.h>
       3  #include <stdlib.h>
       4  
       5  struct X
       6  {
       7    char mem0[10];
       8    char mem1[10];
       9  };
      10  
      11  
      12  void blah (struct X);
      13  
      14  
      15  void
      16  foo1()
      17  {
      18    struct X x = { };
      19    memset (x.mem1, 0, sizeof x.mem1);
      20    blah (x);
      21  }
      22  
      23  void
      24  foo2()
      25  {
      26    struct X x = { };
      27    x.mem1[5] = 0;
      28    blah (x);
      29  }
      30  
      31  void
      32  bar1 ()
      33  {
      34    struct X x;
      35    memset (&x, 0, sizeof x);
      36    memset (&x.mem1, 0, sizeof x.mem1);
      37    blah (x);
      38  }
      39  void
      40  bar2 ()
      41  {
      42    struct X x;
      43    memset (&x, 0, sizeof x);
      44    x.mem1[5] = 0;
      45    blah (x);
      46  }
      47  
      48  void
      49  baz1 ()
      50  {
      51    struct X *x = calloc (sizeof (struct X), 1);
      52    memset (&x->mem1, 0, sizeof x->mem1);
      53    blah (*x);
      54  }
      55  
      56  void
      57  baz2 ()
      58  {
      59    struct X *x = calloc (sizeof (struct X), 1);
      60    x->mem1[5] = 0;
      61    blah (*x);
      62  }
      63  /* { dg-final { scan-tree-dump-times "Deleted redundant call" 3 "dse1" } } */
      64  /* { dg-final { scan-tree-dump-times "Deleted redundant store" 3 "dse1" } } */
      65