aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2017-11-27 11:56:36 +0000
committerEric Botcazou <ebotcazou@adacore.com>2017-11-27 11:56:36 +0000
commit8cb4a46abd1b8b23dcb3da8768f4c79688962f56 (patch)
tree08222828f4dd3f24e1e5561f204474cdf8789d12
parentb9c98ab5ef220c91b24c1ad757f13f0eff370837 (diff)
* cfgloop.h (struct loop): Document usage of USHRT_MAX for unroll.
* loop-unroll.c (decide_unroll_constant_iterations): Implement it. (decide_unroll_runtime_iterations): Likewise. (decide_unroll_stupid): Likewise. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@255165 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/cfgloop.h7
-rw-r--r--gcc/loop-unroll.c6
-rw-r--r--gcc/testsuite/ChangeLog11
-rw-r--r--gcc/testsuite/gnat.dg/unroll1.adb4
-rw-r--r--gcc/testsuite/gnat.dg/unroll1.ads1
-rw-r--r--gcc/testsuite/gnat.dg/unroll2.adb2
-rw-r--r--gcc/testsuite/gnat.dg/unroll2.ads1
-rw-r--r--gcc/testsuite/gnat.dg/unroll3.adb2
-rw-r--r--gcc/testsuite/gnat.dg/unroll3.ads1
-rw-r--r--gcc/testsuite/gnat.dg/unroll4.adb26
-rw-r--r--gcc/testsuite/gnat.dg/unroll4.ads10
-rw-r--r--gcc/testsuite/gnat.dg/unroll4_pkg.ads5
13 files changed, 70 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index eaf26485a13..a7066fb7ad1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2017-11-27 Eric Botcazou <ebotcazou@adacore.com>
+
+ * cfgloop.h (struct loop): Document usage of USHRT_MAX for unroll.
+ * loop-unroll.c (decide_unroll_constant_iterations): Implement it.
+ (decide_unroll_runtime_iterations): Likewise.
+ (decide_unroll_stupid): Likewise.
+
2017-11-27 Igor Tsimbalist <igor.v.tsimbalist@intel.com>
PR target/83109
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index be2ba8cf1a1..dce01bdd56a 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -221,9 +221,10 @@ struct GTY ((chain_next ("%h.next"))) loop {
/* True if the loop is part of an oacc kernels region. */
unsigned in_oacc_kernels_region : 1;
- /* The number of times to unroll the loop. 0, means no information
- given, just do what we always do. A value of 1, means don't unroll
- the loop. */
+ /* The number of times to unroll the loop. 0 means no information given,
+ just do what we always do. A value of 1 means do not unroll the loop.
+ A value of USHRT_MAX means unroll with no specific unrolling factor.
+ Other values means unroll with the given unrolling factor. */
unsigned short unroll;
/* For SIMD loops, this is a unique identifier of the loop, referenced
diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c
index bbba35fbff1..0fdecd7fde2 100644
--- a/gcc/loop-unroll.c
+++ b/gcc/loop-unroll.c
@@ -395,7 +395,7 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
}
/* Check for an explicit unrolling factor. */
- if (loop->unroll)
+ if (loop->unroll > 0 && loop->unroll < USHRT_MAX)
{
/* However we cannot unroll completely at the RTL level a loop with
constant number of iterations; it should have been peeled instead. */
@@ -693,7 +693,7 @@ decide_unroll_runtime_iterations (struct loop *loop, int flags)
if (targetm.loop_unroll_adjust)
nunroll = targetm.loop_unroll_adjust (nunroll, loop);
- if (loop->unroll)
+ if (loop->unroll > 0 && loop->unroll < USHRT_MAX)
nunroll = loop->unroll;
/* Skip big loops. */
@@ -1177,7 +1177,7 @@ decide_unroll_stupid (struct loop *loop, int flags)
if (targetm.loop_unroll_adjust)
nunroll = targetm.loop_unroll_adjust (nunroll, loop);
- if (loop->unroll)
+ if (loop->unroll > 0 && loop->unroll < USHRT_MAX)
nunroll = loop->unroll;
/* Skip big loops. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 04788b63877..cb3835b3e9d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2017-11-27 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/unroll1.ads: Remove alignment clause.
+ * gnat.dg/unroll2.ads: Likewise.
+ * gnat.dg/unroll3.ads: Likewise.
+ * gnat.dg/unroll1.adb: Remove bogus comment terminator.
+ * gnat.dg/unroll2.adb: Likewise.
+ * gnat.dg/unroll3.adb: Likewise.
+ * gnat.dg/unroll4.ad[sb]: New testcase.
+ * gnat.dg/unroll4_pkg.ads: New helper.
+
2017-11-27 Igor Tsimbalist <igor.v.tsimbalist@intel.com>
PR target/83109
diff --git a/gcc/testsuite/gnat.dg/unroll1.adb b/gcc/testsuite/gnat.dg/unroll1.adb
index ff9222de0e0..34d8a8f3f38 100644
--- a/gcc/testsuite/gnat.dg/unroll1.adb
+++ b/gcc/testsuite/gnat.dg/unroll1.adb
@@ -23,5 +23,5 @@ package body Unroll1 is
end Unroll1;
--- { dg-final { scan-tree-dump-times "Not unrolling loop .: user didn't want it unrolled completely" 2 "cunrolli" } } */
--- { dg-final { scan-rtl-dump-times "Not unrolling loop, user didn't want it unrolled" 2 "loop2_unroll" } } */
+-- { dg-final { scan-tree-dump-times "Not unrolling loop .: user didn't want it unrolled completely" 2 "cunrolli" } }
+-- { dg-final { scan-rtl-dump-times "Not unrolling loop, user didn't want it unrolled" 2 "loop2_unroll" } }
diff --git a/gcc/testsuite/gnat.dg/unroll1.ads b/gcc/testsuite/gnat.dg/unroll1.ads
index 28dbea8a9c0..b96762b0da9 100644
--- a/gcc/testsuite/gnat.dg/unroll1.ads
+++ b/gcc/testsuite/gnat.dg/unroll1.ads
@@ -1,7 +1,6 @@
package Unroll1 is
type Sarray is array (1 .. 4) of Float;
- for Sarray'Alignment use 16;
function "+" (X, Y : Sarray) return Sarray;
procedure Add (X, Y : Sarray; R : out Sarray);
diff --git a/gcc/testsuite/gnat.dg/unroll2.adb b/gcc/testsuite/gnat.dg/unroll2.adb
index 01af9d2b788..e4473cc0558 100644
--- a/gcc/testsuite/gnat.dg/unroll2.adb
+++ b/gcc/testsuite/gnat.dg/unroll2.adb
@@ -23,4 +23,4 @@ package body Unroll2 is
end Unroll2;
--- { dg-final { scan-tree-dump-times "note: loop with 3 iterations completely unrolled" 2 "cunrolli" } } */
+-- { dg-final { scan-tree-dump-times "note: loop with 3 iterations completely unrolled" 2 "cunrolli" } }
diff --git a/gcc/testsuite/gnat.dg/unroll2.ads b/gcc/testsuite/gnat.dg/unroll2.ads
index efae982c4c6..342f371f1fe 100644
--- a/gcc/testsuite/gnat.dg/unroll2.ads
+++ b/gcc/testsuite/gnat.dg/unroll2.ads
@@ -1,7 +1,6 @@
package Unroll2 is
type Sarray is array (1 .. 4) of Float;
- for Sarray'Alignment use 16;
function "+" (X, Y : Sarray) return Sarray;
procedure Add (X, Y : Sarray; R : out Sarray);
diff --git a/gcc/testsuite/gnat.dg/unroll3.adb b/gcc/testsuite/gnat.dg/unroll3.adb
index 3a0725b8093..ba4e122530a 100644
--- a/gcc/testsuite/gnat.dg/unroll3.adb
+++ b/gcc/testsuite/gnat.dg/unroll3.adb
@@ -23,4 +23,4 @@ package body Unroll3 is
end Unroll3;
--- { dg-final { scan-tree-dump-times "note: loop with 3 iterations completely unrolled" 2 "cunroll" } } */
+-- { dg-final { scan-tree-dump-times "note: loop with 3 iterations completely unrolled" 2 "cunroll" } }
diff --git a/gcc/testsuite/gnat.dg/unroll3.ads b/gcc/testsuite/gnat.dg/unroll3.ads
index 8264fc7b489..8f0cae1cbfd 100644
--- a/gcc/testsuite/gnat.dg/unroll3.ads
+++ b/gcc/testsuite/gnat.dg/unroll3.ads
@@ -1,7 +1,6 @@
package Unroll3 is
type Sarray is array (1 .. 4) of Float;
- for Sarray'Alignment use 16;
function "+" (X, Y : Sarray) return Sarray;
procedure Add (X, Y : Sarray; R : out Sarray);
diff --git a/gcc/testsuite/gnat.dg/unroll4.adb b/gcc/testsuite/gnat.dg/unroll4.adb
new file mode 100644
index 00000000000..d9b763ae401
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/unroll4.adb
@@ -0,0 +1,26 @@
+-- { dg-do compile }
+-- { dg-options "-O -fdump-rtl-loop2_unroll-details" }
+
+package body Unroll4 is
+
+ function "+" (X, Y : Sarray) return Sarray is
+ R : Sarray;
+ begin
+ for I in Sarray'Range loop
+ pragma Loop_Optimize (Unroll);
+ R(I) := X(I) + Y(I);
+ end loop;
+ return R;
+ end;
+
+ procedure Add (X, Y : Sarray; R : out Sarray) is
+ begin
+ for I in Sarray'Range loop
+ pragma Loop_Optimize (Unroll);
+ R(I) := X(I) + Y(I);
+ end loop;
+ end;
+
+end Unroll4;
+
+-- { dg-final { scan-rtl-dump-times "note: loop unrolled 7 times" 2 "loop2_unroll" } }
diff --git a/gcc/testsuite/gnat.dg/unroll4.ads b/gcc/testsuite/gnat.dg/unroll4.ads
new file mode 100644
index 00000000000..e36bc8070bc
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/unroll4.ads
@@ -0,0 +1,10 @@
+with Unroll4_Pkg; use Unroll4_Pkg;
+
+package Unroll4 is
+
+ type Sarray is array (1 .. N) of Float;
+
+ function "+" (X, Y : Sarray) return Sarray;
+ procedure Add (X, Y : Sarray; R : out Sarray);
+
+end Unroll4;
diff --git a/gcc/testsuite/gnat.dg/unroll4_pkg.ads b/gcc/testsuite/gnat.dg/unroll4_pkg.ads
new file mode 100644
index 00000000000..a0a45b007df
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/unroll4_pkg.ads
@@ -0,0 +1,5 @@
+package Unroll4_Pkg is
+
+ function N return Positive;
+
+end Unroll4_Pkg;