/* Vectorizer
- Copyright (C) 2003-2014 Free Software Foundation, Inc.
+ Copyright (C) 2003-2015 Free Software Foundation, Inc.
Contributed by Dorit Naishlos <dorit@il.ibm.com>
This file is part of GCC.
#include "coretypes.h"
#include "dumpfile.h"
#include "tm.h"
+#include "hash-set.h"
+#include "machmode.h"
+#include "vec.h"
+#include "double-int.h"
+#include "input.h"
+#include "alias.h"
+#include "symtab.h"
+#include "wide-int.h"
+#include "inchash.h"
#include "tree.h"
+#include "fold-const.h"
#include "stor-layout.h"
#include "tree-pretty-print.h"
+#include "predict.h"
+#include "hard-reg-set.h"
+#include "input.h"
+#include "function.h"
+#include "dominance.h"
+#include "cfg.h"
#include "basic-block.h"
#include "tree-ssa-alias.h"
#include "internal-fn.h"
#include "gimple-iterator.h"
#include "gimple-walk.h"
#include "gimple-ssa.h"
+#include "hash-map.h"
+#include "plugin-api.h"
+#include "ipa-ref.h"
#include "cgraph.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
int vf;
/* hash_table support. */
- typedef simduid_to_vf value_type;
- typedef simduid_to_vf compare_type;
- static inline hashval_t hash (const value_type *);
- static inline int equal (const value_type *, const compare_type *);
+ typedef simduid_to_vf *value_type;
+ typedef simduid_to_vf *compare_type;
+ static inline hashval_t hash (const simduid_to_vf *);
+ static inline int equal (const simduid_to_vf *, const simduid_to_vf *);
};
inline hashval_t
-simduid_to_vf::hash (const value_type *p)
+simduid_to_vf::hash (const simduid_to_vf *p)
{
return p->simduid;
}
inline int
-simduid_to_vf::equal (const value_type *p1, const value_type *p2)
+simduid_to_vf::equal (const simduid_to_vf *p1, const simduid_to_vf *p2)
{
return p1->simduid == p2->simduid;
}
unsigned int simduid;
/* hash_table support. */
- typedef simd_array_to_simduid value_type;
- typedef simd_array_to_simduid compare_type;
- static inline hashval_t hash (const value_type *);
- static inline int equal (const value_type *, const compare_type *);
+ typedef simd_array_to_simduid *value_type;
+ typedef simd_array_to_simduid *compare_type;
+ static inline hashval_t hash (const simd_array_to_simduid *);
+ static inline int equal (const simd_array_to_simduid *,
+ const simd_array_to_simduid *);
};
inline hashval_t
-simd_array_to_simduid::hash (const value_type *p)
+simd_array_to_simduid::hash (const simd_array_to_simduid *p)
{
return DECL_UID (p->decl);
}
inline int
-simd_array_to_simduid::equal (const value_type *p1, const value_type *p2)
+simd_array_to_simduid::equal (const simd_array_to_simduid *p1,
+ const simd_array_to_simduid *p2)
{
return p1->decl == p2->decl;
}
into their corresponding constants. */
static void
-adjust_simduid_builtins (hash_table <simduid_to_vf> &htab)
+adjust_simduid_builtins (hash_table<simduid_to_vf> **htab)
{
basic_block bb;
gcc_assert (TREE_CODE (arg) == SSA_NAME);
simduid_to_vf *p = NULL, data;
data.simduid = DECL_UID (SSA_NAME_VAR (arg));
- if (htab.is_created ())
- p = htab.find (&data);
+ if (*htab)
+ p = (*htab)->find (&data);
if (p)
vf = p->vf;
switch (ifn)
struct note_simd_array_uses_struct
{
- hash_table <simd_array_to_simduid> *htab;
+ hash_table<simd_array_to_simduid> **htab;
unsigned int simduid;
};
&& DECL_CONTEXT (*tp) == current_function_decl)
{
simd_array_to_simduid data;
- if (!ns->htab->is_created ())
- ns->htab->create (15);
+ if (!*ns->htab)
+ *ns->htab = new hash_table<simd_array_to_simduid> (15);
data.decl = *tp;
data.simduid = ns->simduid;
- simd_array_to_simduid **slot = ns->htab->find_slot (&data, INSERT);
+ simd_array_to_simduid **slot = (*ns->htab)->find_slot (&data, INSERT);
if (*slot == NULL)
{
simd_array_to_simduid *p = XNEW (simd_array_to_simduid);
simduid. */
static void
-note_simd_array_uses (hash_table <simd_array_to_simduid> *htab)
+note_simd_array_uses (hash_table<simd_array_to_simduid> **htab)
{
basic_block bb;
gimple_stmt_iterator gsi;
update_stmt (use_stmt);
}
}
+/* Set the uids of all the statements in basic blocks inside loop
+ represented by LOOP_VINFO. LOOP_VECTORIZED_CALL is the internal
+ call guarding the loop which has been if converted. */
+static void
+set_uid_loop_bbs (loop_vec_info loop_vinfo, gimple loop_vectorized_call)
+{
+ tree arg = gimple_call_arg (loop_vectorized_call, 1);
+ basic_block *bbs;
+ unsigned int i;
+ struct loop *scalar_loop = get_loop (cfun, tree_to_shwi (arg));
+
+ LOOP_VINFO_SCALAR_LOOP (loop_vinfo) = scalar_loop;
+ gcc_checking_assert (vect_loop_vectorized_call
+ (LOOP_VINFO_SCALAR_LOOP (loop_vinfo))
+ == loop_vectorized_call);
+ bbs = get_loop_body (scalar_loop);
+ for (i = 0; i < scalar_loop->num_nodes; i++)
+ {
+ basic_block bb = bbs[i];
+ gimple_stmt_iterator gsi;
+ for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ {
+ gimple phi = gsi_stmt (gsi);
+ gimple_set_uid (phi, 0);
+ }
+ for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ {
+ gimple stmt = gsi_stmt (gsi);
+ gimple_set_uid (stmt, 0);
+ }
+ }
+ free (bbs);
+}
/* Function vectorize_loops.
unsigned int num_vectorized_loops = 0;
unsigned int vect_loops_num;
struct loop *loop;
- hash_table <simduid_to_vf> simduid_to_vf_htab;
- hash_table <simd_array_to_simduid> simd_array_to_simduid_htab;
+ hash_table<simduid_to_vf> *simduid_to_vf_htab = NULL;
+ hash_table<simd_array_to_simduid> *simd_array_to_simduid_htab = NULL;
bool any_ifcvt_loops = false;
unsigned ret = 0;
if (vect_loops_num <= 1)
{
if (cfun->has_simduid_loops)
- adjust_simduid_builtins (simduid_to_vf_htab);
+ adjust_simduid_builtins (&simduid_to_vf_htab);
return 0;
}
gimple loop_vectorized_call = vect_loop_vectorized_call (loop);
if (loop_vectorized_call)
- {
- tree arg = gimple_call_arg (loop_vectorized_call, 1);
- basic_block *bbs;
- unsigned int i;
- struct loop *scalar_loop = get_loop (cfun, tree_to_shwi (arg));
-
- LOOP_VINFO_SCALAR_LOOP (loop_vinfo) = scalar_loop;
- gcc_checking_assert (vect_loop_vectorized_call
- (LOOP_VINFO_SCALAR_LOOP (loop_vinfo))
- == loop_vectorized_call);
- bbs = get_loop_body (scalar_loop);
- for (i = 0; i < scalar_loop->num_nodes; i++)
- {
- basic_block bb = bbs[i];
- gimple_stmt_iterator gsi;
- for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
- gsi_next (&gsi))
- {
- gimple phi = gsi_stmt (gsi);
- gimple_set_uid (phi, 0);
- }
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
- gsi_next (&gsi))
- {
- gimple stmt = gsi_stmt (gsi);
- gimple_set_uid (stmt, 0);
- }
- }
- free (bbs);
- }
-
+ set_uid_loop_bbs (loop_vinfo, loop_vectorized_call);
if (LOCATION_LOCUS (vect_location) != UNKNOWN_LOCATION
&& dump_enabled_p ())
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
if (loop->simduid)
{
simduid_to_vf *simduid_to_vf_data = XNEW (simduid_to_vf);
- if (!simduid_to_vf_htab.is_created ())
- simduid_to_vf_htab.create (15);
+ if (!simduid_to_vf_htab)
+ simduid_to_vf_htab = new hash_table<simduid_to_vf> (15);
simduid_to_vf_data->simduid = DECL_UID (loop->simduid);
simduid_to_vf_data->vf = loop_vinfo->vectorization_factor;
- *simduid_to_vf_htab.find_slot (simduid_to_vf_data, INSERT)
+ *simduid_to_vf_htab->find_slot (simduid_to_vf_data, INSERT)
= simduid_to_vf_data;
}
/* Fold IFN_GOMP_SIMD_{VF,LANE,LAST_LANE} builtins. */
if (cfun->has_simduid_loops)
- adjust_simduid_builtins (simduid_to_vf_htab);
+ adjust_simduid_builtins (&simduid_to_vf_htab);
/* Shrink any "omp array simd" temporary arrays to the
actual vectorization factors. */
- if (simd_array_to_simduid_htab.is_created ())
+ if (simd_array_to_simduid_htab)
{
- for (hash_table <simd_array_to_simduid>::iterator iter
- = simd_array_to_simduid_htab.begin ();
- iter != simd_array_to_simduid_htab.end (); ++iter)
- if ((*iter).simduid != -1U)
+ for (hash_table<simd_array_to_simduid>::iterator iter
+ = simd_array_to_simduid_htab->begin ();
+ iter != simd_array_to_simduid_htab->end (); ++iter)
+ if ((*iter)->simduid != -1U)
{
- tree decl = (*iter).decl;
+ tree decl = (*iter)->decl;
int vf = 1;
- if (simduid_to_vf_htab.is_created ())
+ if (simduid_to_vf_htab)
{
simduid_to_vf *p = NULL, data;
- data.simduid = (*iter).simduid;
- p = simduid_to_vf_htab.find (&data);
+ data.simduid = (*iter)->simduid;
+ p = simduid_to_vf_htab->find (&data);
if (p)
vf = p->vf;
}
relayout_decl (decl);
}
- simd_array_to_simduid_htab.dispose ();
+ delete simd_array_to_simduid_htab;
}
- if (simduid_to_vf_htab.is_created ())
- simduid_to_vf_htab.dispose ();
+ delete simduid_to_vf_htab;
+ simduid_to_vf_htab = NULL;
if (num_vectorized_loops > 0)
{
GIMPLE_PASS, /* type */
"slp", /* name */
OPTGROUP_LOOP | OPTGROUP_VEC, /* optinfo_flags */
- true, /* has_execute */
TV_TREE_SLP_VECTORIZATION, /* tv_id */
( PROP_ssa | PROP_cfg ), /* properties_required */
0, /* properties_provided */
if (vect_can_force_dr_alignment_p (decl, alignment))
{
- DECL_ALIGN (decl) = TYPE_ALIGN (vectype);
- DECL_USER_ALIGN (decl) = 1;
- if (TREE_STATIC (decl))
- {
- tree target = symtab_alias_ultimate_target (symtab_get_node (decl))->decl;
- DECL_ALIGN (target) = TYPE_ALIGN (vectype);
- DECL_USER_ALIGN (target) = 1;
- }
+ vnode->increase_alignment (TYPE_ALIGN (vectype));
dump_printf (MSG_NOTE, "Increasing alignment of decl: ");
dump_generic_expr (MSG_NOTE, TDF_SLIM, decl);
dump_printf (MSG_NOTE, "\n");
SIMPLE_IPA_PASS, /* type */
"increase_alignment", /* name */
OPTGROUP_LOOP | OPTGROUP_VEC, /* optinfo_flags */
- true, /* has_execute */
TV_IPA_OPT, /* tv_id */
0, /* properties_required */
0, /* properties_provided */