Debian Codegraph @

gcc/testsuite/gcc.target/i386/pr106322.c

raw
1 /* { dg-do run } */
2 /* { dg-require-effective-target ia32 } */
3 /* { dg-options "-O2 -mtune=generic -march=i686" } */
4
5 /* As PR106322, verify this can execute well (not abort). */
6
7 #define N 64
8 typedef unsigned short int uh;
9 typedef unsigned short int uw;
10 uh a[N];
11 uh b[N];
12 uh c[N];
13 uh e[N];
14
15 __attribute__ ((noipa)) void
16 foo ()
17 {
18 for (int i = 0; i < N; i++)
19 c[i] = ((uw) b[i] * (uw) a[i]) >> 16;
20 }
21
22 __attribute__ ((optimize ("-O0"))) void
23 init ()
24 {
25 for (int i = 0; i < N; i++)
26 {
27 a[i] = (uh) (0x7ABC - 0x5 * i);
28 b[i] = (uh) (0xEAB + 0xF * i);
29 e[i] = ((uw) b[i] * (uw) a[i]) >> 16;
30 }
31 }
32
33 __attribute__ ((optimize ("-O0"))) void
34 check ()
35 {
36 for (int i = 0; i < N; i++)
37 {
38 if (c[i] != e[i])
39 __builtin_abort ();
40 }
41 }
42
43 int
44 main ()
45 {
46 init ();
47 foo ();
48 check ();
49
50 return 0;
51 }