summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2014-04-15 08:01:01 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2014-04-15 08:01:01 +0000
commiteb71996d653f229133ef50969b05e1f10826b999 (patch)
treec69fd1fc4cb66f4513f0321b78b2af763ccd4971
parent363cb5d65cefb244b341d66a4e84cf4a588bb32a (diff)
downloadgcc-eb71996d653f229133ef50969b05e1f10826b999.tar.gz
* cfgloop.h (struct loop): Move force_vectorize down.
* gimplify.c (gimple_boolify) <ANNOTATE_EXPR>: Handle new kinds. (gimplify_expr) <ANNOTATE_EXPR>: Minor tweak. * lto-streamer-in.c (input_cfg): Read dont_vectorize field. * lto-streamer-out.c (output_cfg): Write dont_vectorize field. * tree-cfg.c (replace_loop_annotate): Revamp and handle new kinds. * tree-core.h (enum annot_expr_kind): Add new kind values. * tree-inline.c (copy_loops): Copy dont_vectorize field and reorder. * tree-pretty-print.c (dump_generic_node) <ANNOTATE_EXPR>: Handle new kinds. * tree.def (ANNOTATE_EXPR): Tweak comment. ada/ * gcc-interface/trans.c (gnat_gimplify_stmt): Propagate loop hints. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@209403 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/ada/ChangeLog4
-rw-r--r--gcc/ada/gcc-interface/trans.c9
-rw-r--r--gcc/cfgloop.h6
-rw-r--r--gcc/gimplify.c15
-rw-r--r--gcc/lto-streamer-in.c1
-rw-r--r--gcc/lto-streamer-out.c1
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gnat.dg/vect12.adb27
-rw-r--r--gcc/testsuite/gnat.dg/vect12.ads10
-rw-r--r--gcc/testsuite/gnat.dg/vect13.adb27
-rw-r--r--gcc/testsuite/gnat.dg/vect13.ads10
-rw-r--r--gcc/tree-cfg.c82
-rw-r--r--gcc/tree-core.h5
-rw-r--r--gcc/tree-inline.c13
-rw-r--r--gcc/tree-pretty-print.c12
-rw-r--r--gcc/tree.def2
17 files changed, 189 insertions, 54 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ca7dfb51d0e..0cd9d698422 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2014-04-15 Eric Botcazou <ebotcazou@adacore.com>
+
+ * cfgloop.h (struct loop): Move force_vectorize down.
+ * gimplify.c (gimple_boolify) <ANNOTATE_EXPR>: Handle new kinds.
+ (gimplify_expr) <ANNOTATE_EXPR>: Minor tweak.
+ * lto-streamer-in.c (input_cfg): Read dont_vectorize field.
+ * lto-streamer-out.c (output_cfg): Write dont_vectorize field.
+ * tree-cfg.c (replace_loop_annotate): Revamp and handle new kinds.
+ * tree-core.h (enum annot_expr_kind): Add new kind values.
+ * tree-inline.c (copy_loops): Copy dont_vectorize field and reorder.
+ * tree-pretty-print.c (dump_generic_node) <ANNOTATE_EXPR>: Handle new
+ kinds.
+ * tree.def (ANNOTATE_EXPR): Tweak comment.
+
2014-04-14 Jan Hubicka <hubicka@ucw.cz>
* ipa-devirt.c (maybe_record_node): Ignore all non-methods (including
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 76ff91a9d6c..77c7542c895 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,7 @@
+2014-04-15 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/trans.c (gnat_gimplify_stmt): Propagate loop hints.
+
2014-04-14 Paolo Carlini <paolo.carlini@oracle.com>
* gcc-interface/decl.c (gnat_to_gnu_entity, components_to_record):
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 3ab503fb14b..3b6d5bd0d5e 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -7761,6 +7761,15 @@ gnat_gimplify_stmt (tree *stmt_p)
build_int_cst (integer_type_node,
annot_expr_ivdep_kind));
+ if (LOOP_STMT_NO_VECTOR (stmt))
+ gnu_cond = build2 (ANNOTATE_EXPR, TREE_TYPE (gnu_cond), gnu_cond,
+ build_int_cst (integer_type_node,
+ annot_expr_no_vector_kind));
+ if (LOOP_STMT_VECTOR (stmt))
+ gnu_cond = build2 (ANNOTATE_EXPR, TREE_TYPE (gnu_cond), gnu_cond,
+ build_int_cst (integer_type_node,
+ annot_expr_vector_kind));
+
gnu_cond
= build3 (COND_EXPR, void_type_node, gnu_cond, NULL_TREE,
build1 (GOTO_EXPR, void_type_node, gnu_end_label));
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index 2e160b202bb..10a00eab177 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -173,12 +173,12 @@ struct GTY ((chain_next ("%h.next"))) loop {
of the loop can be safely evaluated concurrently. */
int safelen;
- /* True if we should try harder to vectorize this loop. */
- bool force_vectorize;
-
/* True if this loop should never be vectorized. */
bool dont_vectorize;
+ /* True if we should try harder to vectorize this loop. */
+ bool force_vectorize;
+
/* For SIMD loops, this is a unique identifier of the loop, referenced
by IFN_GOMP_SIMD_VF, IFN_GOMP_SIMD_LANE and IFN_GOMP_SIMD_LAST_LANE
builtins. */
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 744178420ab..d7470fbb0a6 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2813,15 +2813,18 @@ gimple_boolify (tree expr)
return expr;
case ANNOTATE_EXPR:
- if ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (expr, 1))
- == annot_expr_ivdep_kind)
+ switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (expr, 1)))
{
+ case annot_expr_ivdep_kind:
+ case annot_expr_no_vector_kind:
+ case annot_expr_vector_kind:
TREE_OPERAND (expr, 0) = gimple_boolify (TREE_OPERAND (expr, 0));
if (TREE_CODE (type) != BOOLEAN_TYPE)
TREE_TYPE (expr) = boolean_type_node;
return expr;
+ default:
+ gcc_unreachable ();
}
- /* FALLTHRU */
default:
if (COMPARISON_CLASS_P (expr))
@@ -7528,7 +7531,7 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
case ANNOTATE_EXPR:
{
tree cond = TREE_OPERAND (*expr_p, 0);
- tree id = TREE_OPERAND (*expr_p, 1);
+ tree kind = TREE_OPERAND (*expr_p, 1);
tree type = TREE_TYPE (cond);
if (!INTEGRAL_TYPE_P (type))
{
@@ -7538,8 +7541,8 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
}
tree tmp = create_tmp_var (type, NULL);
gimplify_arg (&cond, pre_p, EXPR_LOCATION (*expr_p));
- gimple call = gimple_build_call_internal (IFN_ANNOTATE, 2,
- cond, id);
+ gimple call
+ = gimple_build_call_internal (IFN_ANNOTATE, 2, cond, kind);
gimple_call_set_lhs (call, tmp);
gimplify_seq_add_stmt (pre_p, call);
*expr_p = tmp;
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index c3fa7b62192..20835f71d6a 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -718,6 +718,7 @@ input_cfg (struct lto_input_block *ib, struct data_in *data_in,
/* Read OMP SIMD related info. */
loop->safelen = streamer_read_hwi (ib);
+ loop->dont_vectorize = streamer_read_hwi (ib);
loop->force_vectorize = streamer_read_hwi (ib);
loop->simduid = stream_read_tree (ib, data_in);
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index cd324c162bb..55bcffee0b0 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -1693,6 +1693,7 @@ output_cfg (struct output_block *ob, struct function *fn)
/* Write OMP SIMD related info. */
streamer_write_hwi (ob, loop->safelen);
+ streamer_write_hwi (ob, loop->dont_vectorize);
streamer_write_hwi (ob, loop->force_vectorize);
stream_write_tree (ob, loop->simduid, true);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 92c46e4a73c..739e1ecc5bd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-04-15 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/vect12.ad[sb]: New test.
+ * gnat.dg/vect13.ad[sb]: Likewise.
+
2014-04-15 Max Ostapenko <m.ostapenko@partner.samsung.com>
* c-c++-common/asan/null-deref-1.c: Change regexp to pass test
diff --git a/gcc/testsuite/gnat.dg/vect12.adb b/gcc/testsuite/gnat.dg/vect12.adb
new file mode 100644
index 00000000000..f493c8bbb0f
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/vect12.adb
@@ -0,0 +1,27 @@
+-- { dg-do compile { target i?86-*-* x86_64-*-* } }
+-- { dg-options "-O3 -msse2 -fdump-tree-vect-details" }
+
+package body Vect12 is
+
+ function "+" (X, Y : Sarray) return Sarray is
+ R : Sarray;
+ begin
+ for I in Sarray'Range loop
+ pragma Loop_Optimize (No_Vector);
+ 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 (No_Vector);
+ R(I) := X(I) + Y(I);
+ end loop;
+ end;
+
+end Vect12;
+
+-- { dg-final { scan-tree-dump-not "vectorized 1 loops" "vect" } }
+-- { dg-final { cleanup-tree-dump "vect" } }
diff --git a/gcc/testsuite/gnat.dg/vect12.ads b/gcc/testsuite/gnat.dg/vect12.ads
new file mode 100644
index 00000000000..a600d0fa5dc
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/vect12.ads
@@ -0,0 +1,10 @@
+package Vect12 is
+
+ -- Constrained array types are vectorizable
+ 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);
+
+end Vect12;
diff --git a/gcc/testsuite/gnat.dg/vect13.adb b/gcc/testsuite/gnat.dg/vect13.adb
new file mode 100644
index 00000000000..ca765d3b485
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/vect13.adb
@@ -0,0 +1,27 @@
+-- { dg-do compile { target i?86-*-* x86_64-*-* } }
+-- { dg-options "-O3 -msse2 -fdump-tree-vect-details" }
+
+package body Vect13 is
+
+ function "+" (X, Y : Sarray) return Sarray is
+ R : Sarray;
+ begin
+ for I in Sarray'Range loop
+ pragma Loop_Optimize (Vector);
+ 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 (Vector);
+ R(I) := X(I) + Y(I);
+ end loop;
+ end;
+
+end Vect13;
+
+-- { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } }
+-- { dg-final { cleanup-tree-dump "vect" } }
diff --git a/gcc/testsuite/gnat.dg/vect13.ads b/gcc/testsuite/gnat.dg/vect13.ads
new file mode 100644
index 00000000000..7aeac5e527a
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/vect13.ads
@@ -0,0 +1,10 @@
+package Vect13 is
+
+ -- Constrained array types are vectorizable
+ 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);
+
+end Vect13;
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 2f250da23b6..cd35d559590 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -250,9 +250,9 @@ build_gimple_cfg (gimple_seq seq)
}
-/* Search for ANNOTATE call with annot_expr_ivdep_kind; if found, remove
- it and set loop->safelen to INT_MAX. We assume that the annotation
- comes immediately before the condition. */
+/* 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 ()
@@ -266,50 +266,62 @@ replace_loop_annotate ()
{
gsi = gsi_last_bb (loop->header);
stmt = gsi_stmt (gsi);
- if (stmt && gimple_code (stmt) == GIMPLE_COND)
+ if (!(stmt && gimple_code (stmt) == GIMPLE_COND))
+ continue;
+ for (gsi_prev_nondebug (&gsi); !gsi_end_p (gsi); gsi_prev (&gsi))
{
- gsi_prev_nondebug (&gsi);
- if (gsi_end_p (gsi))
- continue;
stmt = gsi_stmt (gsi);
if (gimple_code (stmt) != GIMPLE_CALL)
- continue;
+ break;
if (!gimple_call_internal_p (stmt)
- || gimple_call_internal_fn (stmt) != IFN_ANNOTATE)
- continue;
- if ((annot_expr_kind) tree_to_shwi (gimple_call_arg (stmt, 1))
- != annot_expr_ivdep_kind)
- continue;
+ || 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);
- loop->safelen = INT_MAX;
}
}
- /* Remove IFN_ANNOTATE. Safeguard for the case loop->latch == NULL. */
+ /* Remove IFN_ANNOTATE. Safeguard for the case loop->latch == NULL. */
FOR_EACH_BB_FN (bb, cfun)
{
- gsi = gsi_last_bb (bb);
- stmt = gsi_stmt (gsi);
- if (stmt && gimple_code (stmt) == GIMPLE_COND)
- gsi_prev_nondebug (&gsi);
- if (gsi_end_p (gsi))
- continue;
- stmt = gsi_stmt (gsi);
- if (gimple_code (stmt) != GIMPLE_CALL)
- continue;
- if (!gimple_call_internal_p (stmt)
- || gimple_call_internal_fn (stmt) != IFN_ANNOTATE)
- continue;
- if ((annot_expr_kind) tree_to_shwi (gimple_call_arg (stmt, 1))
- != annot_expr_ivdep_kind)
- continue;
- warning_at (gimple_location (stmt), 0, "ignoring %<GCC ivdep%> "
- "annotation");
- stmt = gimple_build_assign (gimple_call_lhs (stmt),
- gimple_call_arg (stmt, 0));
- gsi_replace (&gsi, stmt, true);
+ for (gsi = gsi_last_bb (bb); !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:
+ case annot_expr_no_vector_kind:
+ case annot_expr_vector_kind:
+ break;
+ 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));
+ gsi_replace (&gsi, stmt, true);
+ }
}
}
diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index 1719c7e664e..373a9d689e0 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -657,7 +657,10 @@ enum tree_node_kind {
};
enum annot_expr_kind {
- annot_expr_ivdep_kind
+ annot_expr_ivdep_kind,
+ annot_expr_no_vector_kind,
+ annot_expr_vector_kind,
+ annot_expr_kind_last
};
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 7133c3cfc81..dea8521d3e6 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -2349,17 +2349,18 @@ copy_loops (copy_body_data *id,
place_new_loop (cfun, dest_loop);
flow_loop_tree_node_add (dest_parent, dest_loop);
- if (src_loop->simduid)
- {
- dest_loop->simduid = remap_decl (src_loop->simduid, id);
- cfun->has_simduid_loops = true;
- }
+ dest_loop->safelen = src_loop->safelen;
+ dest_loop->dont_vectorize = src_loop->dont_vectorize;
if (src_loop->force_vectorize)
{
dest_loop->force_vectorize = true;
cfun->has_force_vectorize_loops = true;
}
- dest_loop->safelen = src_loop->safelen;
+ if (src_loop->simduid)
+ {
+ dest_loop->simduid = remap_decl (src_loop->simduid, id);
+ cfun->has_simduid_loops = true;
+ }
/* Recurse. */
copy_loops (id, dest_loop, src_loop);
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index 83d5ca62d6c..bf3b96629c2 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -2105,13 +2105,21 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
case ANNOTATE_EXPR:
pp_string (buffer, "ANNOTATE_EXPR <");
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
{
case annot_expr_ivdep_kind:
- pp_string (buffer, "ivdep, ");
+ pp_string (buffer, ", ivdep");
+ break;
+ case annot_expr_no_vector_kind:
+ pp_string (buffer, ", no-vector");
+ break;
+ case annot_expr_vector_kind:
+ pp_string (buffer, ", vector");
break;
+ default:
+ gcc_unreachable ();
}
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
pp_greater (buffer);
break;
diff --git a/gcc/tree.def b/gcc/tree.def
index f8d64447d51..a92d86f32b0 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -1280,7 +1280,7 @@ DEFTREECODE (TARGET_OPTION_NODE, "target_option_node", tcc_exceptional, 0)
/* ANNOTATE_EXPR.
Operand 0 is the expression to be annotated.
- Operand 1 is the annotation id. */
+ Operand 1 is the annotation kind. */
DEFTREECODE (ANNOTATE_EXPR, "annotate_expr", tcc_expression, 2)
/* Cilk spawn statement