2 /* { dg-options "-O3 -floop-unroll-and-jam --param unroll-jam-min-percent=0 -fdump-tree-unrolljam-details" } */
3 /* { dg-require-effective-target int32plus } */
6 extern unsigned int a
[];
7 extern unsigned int b
[];
8 extern unsigned int aa
[][1024];
14 for (i
= 0; i
< 1024; i
++) {
15 for (j
= 0; j
< 16; j
++) {
16 sum
+= aa
[j
][i
]*31+47;
19 checksum
= checksum
* 27 + sum
;
20 //printf(" %d\n", sum);
27 for (i
= 0; i
< 1024; i
++) {
30 checksum
= checksum
* 27 + sum
;
31 //printf(" %d\n", sum);
34 #define TEST(name, body, test) \
35 static void __attribute__((noinline,noclone)) name (unsigned long n, unsigned long m) \
38 for (i = 1; i < m; i++) { \
39 for (j = 1; j < n; j++) { \
45 static void __attribute__((noinline,noclone,optimize("O1"))) name ## noopt (unsigned long n, unsigned long m) \
48 for (i = 1; i < m; i++) { \
49 for (j = 1; j < n; j++) { \
55 TEST(foo1
, aa
[i
+1][j
+1]=aa
[i
][j
] * aa
[i
][j
] / 2, checkaa()) //ok, -1,-1
56 TEST(foo2
, aa
[i
][j
+1]=3*aa
[i
+1][j
], checkaa()) //notok, 1,-1
57 TEST(foo3
, aa
[i
+1][j
-1]=aa
[i
][j
] * aa
[i
][j
] / 2, checkaa()) //notok, -1,1
58 TEST(foo4
, aa
[i
][j
] = aa
[i
-1][j
+1] * aa
[i
-1][j
+1] / 2, checkaa()) //notok, -1,1
59 TEST(foo5
, aa
[i
][j
] = aa
[i
+1][j
+1] * aa
[i
+1][j
+1] / 2, checkaa()) //ok, 1,1
60 TEST(foo6
, aa
[i
][j
] = aa
[i
+1][j
] * aa
[i
+1][j
] / 2, checkaa()) //ok, -1,0
61 TEST(foo7
, aa
[i
+1][j
] = aa
[i
][j
] * aa
[i
][j
] / 2, checkaa()) //ok, 1,0
62 TEST(foo9
, b
[j
] = 3*b
[j
+1] + 1, checkb()) //notok, 0,-1
63 TEST(foo10
, b
[j
] = 3*b
[j
] + 1, checkb()) //ok, 0,0
65 /* foo8 should work as well, but currently doesn't because the distance
66 vectors we compute are too pessimistic. We compute
67 (0,1), (1,1) and (1,-1)
68 and the last one causes us to lose. */
69 TEST(foo8
, b
[j
+1] = 3*b
[j
] + 1, checkb()) //ok, 0,1
73 unsigned int aa
[16][1024];
77 for (i
= 0; i
< 1024; i
++) {
78 for (j
= 0; j
< 16; j
++) {
79 aa
[j
][i
] = ((j
+1)*2+i
+1) % 17;
81 a
[i
] = ((i
+1)*31) % 19;
82 b
[i
] = ((i
+1)*47) % 23;
88 printf(" %s\n", #name); \
89 init();for(i=0;i<4;i++)name##noopt(32,8); checka = checksum; \
90 init();for(i=0;i<4;i++)name(32,8); \
91 printf("%sok %s\n", checka != checksum ? "NOT " : "", #name);
110 /* Five loops should be unroll-jammed (actually six, but see above). */
111 /* { dg-final { scan-tree-dump-times "applying unroll and jam" 5 "unrolljam" } } */