aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2019-10-22 12:25:03 +0000
committerMichael Matz <matz@suse.de>2019-10-22 12:25:03 +0000
commit87b5b79da8a95da55f2513dffd84c64e3eadcf5d (patch)
treedc1d1782a0e0eb5a953e17ec69cebac7ecb7c6d7 /gcc/testsuite
parent62d3163e55fdd551bb4797dca4f45816d88c5a1e (diff)
Fix PR middle-end/90796
PR middle-end/90796 * gimple-loop-jam.c (any_access_function_variant_p): New function. (adjust_unroll_factor): Use it to constrain safety, new parameter. (tree_loop_unroll_and_jam): Adjust call and profitable unroll factor. testsuite/ * gcc.dg/unroll-and-jam.c: Add three invalid and one valid case. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@277287 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/unroll-and-jam.c22
2 files changed, 23 insertions, 4 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9827b38387d..9caf60787d4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-10-22 Michael Matz <matz@suse.de>
+
+ PR middle-end/90796
+ * gcc.dg/unroll-and-jam.c: Add three invalid and one valid case.
+
2019-10-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/92173
diff --git a/gcc/testsuite/gcc.dg/unroll-and-jam.c b/gcc/testsuite/gcc.dg/unroll-and-jam.c
index 70910d318cb..bcfe1bda9b0 100644
--- a/gcc/testsuite/gcc.dg/unroll-and-jam.c
+++ b/gcc/testsuite/gcc.dg/unroll-and-jam.c
@@ -31,10 +31,10 @@ void checkb(void)
//printf(" %d\n", sum);
}
+unsigned i, j;
#define TEST(name, body, test) \
static void __attribute__((noinline,noclone)) name (unsigned long n, unsigned long m) \
{ \
- unsigned long i, j; \
for (i = 1; i < m; i++) { \
for (j = 1; j < n; j++) { \
body; \
@@ -58,9 +58,14 @@ TEST(foo3, aa[i+1][j-1]=aa[i][j] * aa[i][j] / 2, checkaa()) //notok, -1,1
TEST(foo4, aa[i][j] = aa[i-1][j+1] * aa[i-1][j+1] / 2, checkaa()) //notok, -1,1
TEST(foo5, aa[i][j] = aa[i+1][j+1] * aa[i+1][j+1] / 2, checkaa()) //ok, 1,1
TEST(foo6, aa[i][j] = aa[i+1][j] * aa[i+1][j] / 2, checkaa()) //ok, -1,0
+TEST(foo61, aa[i][0] = aa[i+1][0] * aa[i+1][0] / 2, checkaa()) //notok, -1,0
+TEST(foo62, aa[i][j/2] = aa[i+1][j/2] * aa[i+1][j/2] / 2, checkaa()) //notok, not affine
+TEST(foo63, aa[i][j%2] = aa[i+1][j%2] * aa[i+1][j%2] / 2, checkaa()) //notok, not affine
TEST(foo7, aa[i+1][j] = aa[i][j] * aa[i][j] / 2, checkaa()) //ok, 1,0
TEST(foo9, b[j] = 3*b[j+1] + 1, checkb()) //notok, 0,-1
TEST(foo10, b[j] = 3*b[j] + 1, checkb()) //ok, 0,0
+extern int f;
+TEST(foo11, f = b[i-1] = 1 + 3* b[i+1], checkb()) //ok, 2,0 but must reduce unroll factor to 2, (it would be incorrect with unroll-by-3, which the profitability would suggest)
/* foo8 should work as well, but currently doesn't because the distance
vectors we compute are too pessimistic. We compute
@@ -68,6 +73,7 @@ TEST(foo10, b[j] = 3*b[j] + 1, checkb()) //ok, 0,0
and the last one causes us to lose. */
TEST(foo8, b[j+1] = 3*b[j] + 1, checkb()) //ok, 0,1
+int f;
unsigned int a[1024];
unsigned int b[1024];
unsigned int aa[16][1024];
@@ -88,10 +94,12 @@ void init(void)
printf(" %s\n", #name); \
init();for(i=0;i<4;i++)name##noopt(32,8); checka = checksum; \
init();for(i=0;i<4;i++)name(32,8); \
+ if (checka != checksum) fail = 1; \
printf("%sok %s\n", checka != checksum ? "NOT " : "", #name);
int main()
{
+ int fail = 0;
int i;
unsigned checka;
RUN(foo1);
@@ -100,12 +108,18 @@ int main()
RUN(foo4);
RUN(foo5);
RUN(foo6);
+ RUN(foo61);
+ RUN(foo62);
+ RUN(foo63);
RUN(foo7);
RUN(foo8);
RUN(foo9);
RUN(foo10);
- return 0;
+ RUN(foo11);
+ if (fail)
+ __builtin_abort();
+ return fail;
}
-/* Five loops should be unroll-jammed (actually six, but see above). */
-/* { dg-final { scan-tree-dump-times "applying unroll and jam" 5 "unrolljam" } } */
+/* Six loops should be unroll-jammed (actually seven, but see above). */
+/* { dg-final { scan-tree-dump-times "applying unroll and jam" 6 "unrolljam" } } */