aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2014-11-15 12:34:20 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2014-11-15 12:34:20 +0000
commit8a9b4fa113286697f34dc57ffb1af08108080c9a (patch)
tree081ab31c4d445cce3f0630d61493e9f6ccbb4777 /gcc
parentd03f2c17a2152d2398ad30718d8f050fcd1304a0 (diff)
downloadgcc-8a9b4fa113286697f34dc57ffb1af08108080c9a.zip
gcc-8a9b4fa113286697f34dc57ffb1af08108080c9a.tar.gz
gcc-8a9b4fa113286697f34dc57ffb1af08108080c9a.tar.bz2
tree-cfg.c (replace_loop_annotate_in_block): New function extracted from...
* tree-cfg.c (replace_loop_annotate_in_block): New function extracted from... (replace_loop_annotate): ...here. Call it on the header and on the latch block, if any. Restore proper behavior of final cleanup. From-SVN: r217602
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/opt44.adb19
-rw-r--r--gcc/testsuite/gnat.dg/opt44.ads8
-rw-r--r--gcc/tree-cfg.c88
5 files changed, 92 insertions, 34 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b6f6279..bbf3a80 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2014-11-15 Eric Botcazou <ebotcazou@adacore.com>
+ * tree-cfg.c (replace_loop_annotate_in_block): New function extracted
+ from...
+ (replace_loop_annotate): ...here. Call it on the header and on the
+ latch block, if any. Restore proper behavior of final cleanup.
+
+2014-11-15 Eric Botcazou <ebotcazou@adacore.com>
+
* tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): Add log message
for max-completely-peeled-insns limit.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3359655..7f105cc 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-15 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/opt44.ad[sb]: New test.
+
2014-11-15 Tobias Burnus <burnus@net-b.de>
* gfortran.dg/binding_label_tests_4.f03: Add dg-excess-errors.
diff --git a/gcc/testsuite/gnat.dg/opt44.adb b/gcc/testsuite/gnat.dg/opt44.adb
new file mode 100644
index 0000000..0bd4d6b
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt44.adb
@@ -0,0 +1,19 @@
+-- { dg-do compile }
+-- { dg-options "-O" }
+
+package body Opt44 is
+
+ procedure Addsub (X, Y : Sarray; R : out Sarray; N : Integer) is
+ begin
+ for I in Sarray'Range loop
+ pragma Loop_Optimize (Ivdep);
+ pragma Loop_Optimize (Vector);
+ if N > 0 then
+ R(I) := X(I) + Y(I);
+ else
+ R(I) := X(I) - Y(I);
+ end if;
+ end loop;
+ end;
+
+end Opt44;
diff --git a/gcc/testsuite/gnat.dg/opt44.ads b/gcc/testsuite/gnat.dg/opt44.ads
new file mode 100644
index 0000000..4382272
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt44.ads
@@ -0,0 +1,8 @@
+package Opt44 is
+
+ type Sarray is array (1 .. 4) of Float;
+ for Sarray'Alignment use 16;
+
+ procedure Addsub (X, Y : Sarray; R : out Sarray; N : Integer);
+
+end Opt44;
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 904f2dd..ae7734c 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -265,13 +265,56 @@ build_gimple_cfg (gimple_seq seq)
discriminator_per_locus = NULL;
}
+/* Look for ANNOTATE calls with loop annotation kind in BB; if found, remove
+ them and propagate the information to LOOP. We assume that the annotations
+ come immediately before the condition in BB, if any. */
+
+static void
+replace_loop_annotate_in_block (basic_block bb, struct loop *loop)
+{
+ gimple_stmt_iterator gsi = gsi_last_bb (bb);
+ gimple stmt = gsi_stmt (gsi);
+
+ if (!(stmt && gimple_code (stmt) == GIMPLE_COND))
+ return;
+
+ for (gsi_prev_nondebug (&gsi); !gsi_end_p (gsi); gsi_prev (&gsi))
+ {
+ stmt = gsi_stmt (gsi);
+ if (gimple_code (stmt) != GIMPLE_CALL)
+ break;
+ if (!gimple_call_internal_p (stmt)
+ || gimple_call_internal_fn (stmt) != IFN_ANNOTATE)
+ break;
+
+ switch ((annot_expr_kind) tree_to_shwi (gimple_call_arg (stmt, 1)))
+ {
+ case annot_expr_ivdep_kind:
+ loop->safelen = INT_MAX;
+ break;
+ case annot_expr_no_vector_kind:
+ loop->dont_vectorize = true;
+ break;
+ case annot_expr_vector_kind:
+ loop->force_vectorize = true;
+ cfun->has_force_vectorize_loops = true;
+ break;
+ default:
+ gcc_unreachable ();
+ }
+
+ stmt = gimple_build_assign (gimple_call_lhs (stmt),
+ gimple_call_arg (stmt, 0));
+ gsi_replace (&gsi, stmt, true);
+ }
+}
/* Look for ANNOTATE calls with loop annotation kind; if found, remove
them and propagate the information to the loop. We assume that the
annotations come immediately before the condition of the loop. */
static void
-replace_loop_annotate ()
+replace_loop_annotate (void)
{
struct loop *loop;
basic_block bb;
@@ -280,37 +323,12 @@ replace_loop_annotate ()
FOR_EACH_LOOP (loop, 0)
{
- gsi = gsi_last_bb (loop->header);
- stmt = gsi_stmt (gsi);
- if (!(stmt && gimple_code (stmt) == GIMPLE_COND))
- continue;
- for (gsi_prev_nondebug (&gsi); !gsi_end_p (gsi); gsi_prev (&gsi))
- {
- stmt = gsi_stmt (gsi);
- if (gimple_code (stmt) != GIMPLE_CALL)
- break;
- if (!gimple_call_internal_p (stmt)
- || gimple_call_internal_fn (stmt) != IFN_ANNOTATE)
- break;
- switch ((annot_expr_kind) tree_to_shwi (gimple_call_arg (stmt, 1)))
- {
- case annot_expr_ivdep_kind:
- loop->safelen = INT_MAX;
- break;
- case annot_expr_no_vector_kind:
- loop->dont_vectorize = true;
- break;
- case annot_expr_vector_kind:
- loop->force_vectorize = true;
- cfun->has_force_vectorize_loops = true;
- break;
- default:
- gcc_unreachable ();
- }
- stmt = gimple_build_assign (gimple_call_lhs (stmt),
- gimple_call_arg (stmt, 0));
- gsi_replace (&gsi, stmt, true);
- }
+ /* First look into the header. */
+ replace_loop_annotate_in_block (loop->header, loop);
+
+ /* Then look into the latch, if any. */
+ if (loop->latch)
+ replace_loop_annotate_in_block (loop->latch, loop);
}
/* Remove IFN_ANNOTATE. Safeguard for the case loop->latch == NULL. */
@@ -320,10 +338,11 @@ replace_loop_annotate ()
{
stmt = gsi_stmt (gsi);
if (gimple_code (stmt) != GIMPLE_CALL)
- break;
+ continue;
if (!gimple_call_internal_p (stmt)
|| gimple_call_internal_fn (stmt) != IFN_ANNOTATE)
- break;
+ continue;
+
switch ((annot_expr_kind) tree_to_shwi (gimple_call_arg (stmt, 1)))
{
case annot_expr_ivdep_kind:
@@ -333,6 +352,7 @@ replace_loop_annotate ()
default:
gcc_unreachable ();
}
+
warning_at (gimple_location (stmt), 0, "ignoring loop annotation");
stmt = gimple_build_assign (gimple_call_lhs (stmt),
gimple_call_arg (stmt, 0));