summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr53942.c
blob: 6a51d2673dd7313c21312ce4b09cdda12798c819 (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
/* PR rtl-optimization/53942 */
/* { dg-do compile } */
/* { dg-options "-O2" } */
/* { dg-additional-options "-mtune=pentium2" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */

struct S
{
  unsigned short w[3];
  unsigned int x, y;
};

struct S *baz (void);

__attribute__ ((noinline))
static unsigned char
foo (struct S *x, unsigned char y)
{
  unsigned char c = 0;
  unsigned char v = x->w[0];
  c |= v;
  v = ((x->w[1]) & (1 << y)) ? 1 : 0;
  c |= v << 1;
  v = ((x->w[2]) & 0xff) & (1 << y);
  c |= v << 2;
  return c;
}

void
bar (void)
{
  struct S *s = baz ();
  s->x = foo (s, 6);
  s->y = foo (s, 7);
}