summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/loop-iv.c2
-rw-r--r--gcc/loop-unroll.c6
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/unroll-6.c4
-rw-r--r--gcc/testsuite/gcc.dg/unroll-7.c14
-rw-r--r--gcc/testsuite/gcc.dg/unroll-8.c15
7 files changed, 49 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 58fea2fca68..d7321aeff2f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2016-06-01 Jan Hubicka <hubicka@ucw.cz>
+
+ * loop-unroll.c (decide_unroll_constant_iterations,
+ decide_unroll_runtime_iterations, decide_unroll_stupid): Use
+ likely upper bounds.
+ * loop-iv.c (find_simple_exit): Dump likely upper bounds.
+
2016-06-01 Thomas Schwinge <thomas@codesourcery.com>
* tree-core.h (enum omp_clause_code): Remove
diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c
index fecaf8f110a..57fb8c1fa7f 100644
--- a/gcc/loop-iv.c
+++ b/gcc/loop-iv.c
@@ -2998,6 +2998,8 @@ find_simple_exit (struct loop *loop, struct niter_desc *desc)
fprintf (dump_file, " upper bound: %li\n",
(long)get_max_loop_iterations_int (loop));
+ fprintf (dump_file, " likely upper bound: %li\n",
+ (long)get_likely_max_loop_iterations_int (loop));
fprintf (dump_file, " realistic bound: %li\n",
(long)get_estimated_loop_iterations_int (loop));
}
diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c
index 97735a89e58..42b1548d1ff 100644
--- a/gcc/loop-unroll.c
+++ b/gcc/loop-unroll.c
@@ -396,7 +396,7 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
of iterations. */
if (desc->niter < 2 * nunroll
|| ((get_estimated_loop_iterations (loop, &iterations)
- || get_max_loop_iterations (loop, &iterations))
+ || get_likely_max_loop_iterations (loop, &iterations))
&& wi::ltu_p (iterations, 2 * nunroll)))
{
if (dump_file)
@@ -706,7 +706,7 @@ decide_unroll_runtime_iterations (struct loop *loop, int flags)
/* Check whether the loop rolls. */
if ((get_estimated_loop_iterations (loop, &iterations)
- || get_max_loop_iterations (loop, &iterations))
+ || get_likely_max_loop_iterations (loop, &iterations))
&& wi::ltu_p (iterations, 2 * nunroll))
{
if (dump_file)
@@ -1162,7 +1162,7 @@ decide_unroll_stupid (struct loop *loop, int flags)
/* Check whether the loop rolls. */
if ((get_estimated_loop_iterations (loop, &iterations)
- || get_max_loop_iterations (loop, &iterations))
+ || get_likely_max_loop_iterations (loop, &iterations))
&& wi::ltu_p (iterations, 2 * nunroll))
{
if (dump_file)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fc864d35b6d..75d8504da76 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2016-06-01 Jan Hubicka <hubicka@ucw.cz>
+
+ * gcc.dg/unroll-6.c: Update template.
+ * gcc.dg/unroll-7.c: New testcase.
+ * gcc.dg/unroll-8.c: New testcase.
+
2016-06-01 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt56.ad[sb]: New test.
diff --git a/gcc/testsuite/gcc.dg/unroll-6.c b/gcc/testsuite/gcc.dg/unroll-6.c
index 8e8b7264fcd..e4c231ea79f 100644
--- a/gcc/testsuite/gcc.dg/unroll-6.c
+++ b/gcc/testsuite/gcc.dg/unroll-6.c
@@ -28,7 +28,7 @@ int t2()
abort ();
return 0;
}
-/* { dg-final { scan-rtl-dump-times "upper bound: 999999" 1 "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump-times " upper bound: 999999" 1 "loop2_unroll" } } */
/* { dg-final { scan-rtl-dump-not "realistic bound: 999999" "loop2_unroll" } } */
-/* { dg-final { scan-rtl-dump-times "upper bound: 2999999" 1 "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump-times " upper bound: 2999999" 1 "loop2_unroll" } } */
/* { dg-final { scan-rtl-dump-times "realistic bound: 2999999" 1 "loop2_unroll" } } */
diff --git a/gcc/testsuite/gcc.dg/unroll-7.c b/gcc/testsuite/gcc.dg/unroll-7.c
new file mode 100644
index 00000000000..e7fa4cf0a8c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/unroll-7.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll -funroll-loops" } */
+int t(int *a)
+{
+ int i;
+ for (i=0;i<1000000;i++)
+ a[i]++;
+}
+/* { dg-final { scan-rtl-dump "Unrolled loop" "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump "number of iterations: .const_int 999999" "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump "upper bound: 999999" "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump "realistic bound: 999999" "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump "Considering unrolling loop with constant number of iterations" "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump-not "Invalid sum" "loop2_unroll" } } */
diff --git a/gcc/testsuite/gcc.dg/unroll-8.c b/gcc/testsuite/gcc.dg/unroll-8.c
new file mode 100644
index 00000000000..b16df672833
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/unroll-8.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll -funroll-loops" } */
+struct a {int a[7];};
+int t(struct a *a, int n)
+{
+ int i;
+ for (i=0;i<n;i++)
+ a->a[i]++;
+}
+/* { dg-final { scan-rtl-dump-not "Unrolled loop" "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump "likely upper bound: 7" "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump "realistic bound: -1" "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump "Not unrolling loop, doesn't roll" "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump-not "Invalid sum" "loop2_unroll" } } */
+/* { dg-final { scan-rtl-dump-not "upper bound: -1" "loop2_unroll" } } */