(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
store_merging_20.c
       1  /* { dg-do run } */
       2  /* { dg-require-effective-target store_merge } */
       3  /* { dg-options "-O2 -fdump-tree-store-merging" } */
       4  
       5  extern void abort (void);
       6  
       7  struct S1 {
       8    unsigned int flag : 1;
       9    unsigned int size : 31;
      10  };
      11  
      12  __attribute__((noipa))
      13  void foo1 (struct S1 *s, unsigned int size)
      14  {
      15    s->flag = 1;
      16    s->size = size & 0x7FFFFFFF;
      17  }
      18  
      19  struct S2 {
      20    unsigned int flag : 1;
      21    unsigned int size : 15;
      22    unsigned short count;
      23  };
      24  
      25  __attribute__((noipa))
      26  void foo2 (struct S2 *s, unsigned short size)
      27  {
      28    s->flag = 1;
      29    s->size = size;
      30    s->count = 0xABCD;
      31  }
      32  
      33  struct S3 {
      34    unsigned int n1 : 4;
      35    unsigned int c  : 8;
      36    unsigned int n2 : 4;
      37  };
      38  
      39  __attribute__((noipa))
      40  void foo3 (struct S3 *s, unsigned char n1, unsigned char c, unsigned char n2)
      41  {
      42    s->n1 = n1 & 0xF;
      43    s->n2 = n2 & 0xF;
      44    s->c = c;
      45  }
      46  
      47  int main (void)
      48  {
      49    struct S1 s1;
      50    struct S2 s2;
      51    struct S3 s3;
      52  
      53    foo1 (&s1, 0x12345678);
      54    if (s1.flag != 1 || s1.size != 0x12345678)
      55      abort ();
      56  
      57    foo2 (&s2, 0x1234);
      58    if (s2.flag != 1 || s2.size != 0x1234 || s2.count != 0xABCD)
      59      abort ();
      60  
      61    foo3 (&s3, 0x12, 0x34, 0x56);
      62    if (s3.n1 != 0x2 || s3.c != 0x34 || s3.n2 != 0x6)
      63      abort ();
      64  
      65    return 0;
      66  }
      67  
      68  /* { dg-final { scan-tree-dump-times "Merging successful" 3 "store-merging" } } */