summaryrefslogtreecommitdiffstats
path: root/gcc/testsuite/gcc.dg/misaligned-expand-1.c
blob: b799b6b87c2a8d334eb05956005782b39cbdb442 (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
/* Test that expand can generate correct loads of misaligned data even on
   strict alignment platforms.  */

/* { dg-do run } */
/* { dg-options "-O0" } */

extern void abort ();

typedef unsigned int myint __attribute__((aligned(1)));

unsigned int
foo (myint *p)
{
  return *p;
}

#define cst (int) 0xdeadbeef
#define NUM 8

struct blah
{
  char c;
  myint i[NUM];
};

struct blah g;

int
main (int argc, char **argv)
{
  int i, k;
  for (k = 0; k < NUM; k++)
    {
      g.i[k] = cst;
      i = foo (&g.i[k]);

      if (i != cst)
	abort ();
    }
  return 0;
}
OpenPOWER on IntegriCloud