summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-bitand-2.c
blob: de2e67449b1fe25ce22978659f4c71af738652cc (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
/* { dg-do compile } */
/* { dg-options "-fdump-tree-original" } */

struct {
  char c1;
  char c2;
  char c3;
  char c4;
} s __attribute__ ((aligned (4)));

unsigned f1 (void)
{
  return 3 & (__SIZE_TYPE__)&s.c1;
}

unsigned f2 (void)
{
  return 3 & (__SIZE_TYPE__)&s.c2;
}

unsigned f3 (void)
{
  return 3 & (__SIZE_TYPE__)&s.c3;
}

unsigned f4 (void)
{
  return 3 & (__SIZE_TYPE__)&s.c4;
}

unsigned f5 (void)
{
  return 4 & (__SIZE_TYPE__)&s.c1;
}

/* { dg-final { scan-tree-dump-times "\& 3" 0 "original" } } */
/* { dg-final { scan-tree-dump-times "\& 4" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "return 0" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "return 1" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "return 2" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "return 3" 1 "original" } } */
/* { dg-final { cleanup-tree-dump "original" } } */