aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/powerpc/pr106322.c
blob: c05072d34162b9290822b2f748cb7b66c6179dd4 (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
43
44
45
46
47
48
49
50
/* { dg-do run } */
/* { dg-options "-O2 -mdejagnu-cpu=power4" } */

/* As PR106322, verify this can execute well (not abort).  */

#define N 64
typedef unsigned short int uh;
typedef unsigned short int uw;
uh a[N];
uh b[N];
uh c[N];
uh e[N];

__attribute__ ((noipa)) void
foo ()
{
  for (int i = 0; i < N; i++)
    c[i] = ((uw) b[i] * (uw) a[i]) >> 16;
}

__attribute__ ((optimize ("-O0"))) void
init ()
{
  for (int i = 0; i < N; i++)
    {
      a[i] = (uh) (0x7ABC - 0x5 * i);
      b[i] = (uh) (0xEAB + 0xF * i);
      e[i] = ((uw) b[i] * (uw) a[i]) >> 16;
    }
}

__attribute__ ((optimize ("-O0"))) void
check ()
{
  for (int i = 0; i < N; i++)
    {
      if (c[i] != e[i])
	__builtin_abort ();
    }
}

int
main ()
{
  init ();
  foo ();
  check ();

  return 0;
}