+2013-08-29 Xinliang David Li <davidxl@google.com>
+
+ * tree-vect-slp.c (destroy_bb_vec_info): Data ref cleanup.
+ * tree-vect-loop.c (destroy_bb_vec_info): Ditto.
+ * tree-vect-data-refs.c (vect_compute_data_ref_alignment):
+ Delay base decl alignment adjustment.
+ * tree-vectorizer.c (vect_destroy_datarefs): New function.
+ * tree-vectorizer.h: New data structure.
+ (set_dr_misalignment): New function.
+ (dr_misalignment): Ditto.
+ * tree-vect-stmts.c (vectorizable_store): Ensure alignment.
+ (vectorizable_load): Ditto.
+ (ensure_base_align): New function.
+ (vectorize_loops): Add dbg_cnt support.
+ (execute_vect_slp): Ditto.
+ * dbgcnt.def: New debug counter.
+ * Makefile: New dependency.
+
2013-09-03 Meador Inge <meadori@codesourcery.com>
Revert:
tree-vectorizer.o: tree-vectorizer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(DUMPFILE_H) $(TM_H) $(GGC_H) $(TREE_H) $(TREE_FLOW_H) \
$(CFGLOOP_H) $(TREE_PASS_H) $(TREE_VECTORIZER_H) \
- $(TREE_PRETTY_PRINT_H)
+ $(TREE_PRETTY_PRINT_H) $(DBGCNT_H)
vtable-verify.o: vtable-verify.c vtable-verify.h $(CONFIG_H) \
$(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) cp/cp-tree.h $(TM_P_H) \
$(BASIC_BLOCK_H) output.h $(TREE_FLOW_H) $(TREE_DUMP_H) $(TREE_PASS_H) \
DEBUG_COUNTER (treepre_insert)
DEBUG_COUNTER (tree_sra)
DEBUG_COUNTER (eipa_sra)
+DEBUG_COUNTER (vect_loop)
+DEBUG_COUNTER (vect_slp)
DEBUG_COUNTER (sched2_func)
DEBUG_COUNTER (sched_block)
DEBUG_COUNTER (sched_func)
dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
}
- DECL_ALIGN (base) = TYPE_ALIGN (vectype);
- DECL_USER_ALIGN (base) = 1;
+ gcc_assert (dr->aux);
+ ((dataref_aux *)dr->aux)->base_decl = base;
+ ((dataref_aux *)dr->aux)->base_misaligned = true;
}
- /* At this point we assume that the base is aligned. */
- gcc_assert (base_aligned
- || (TREE_CODE (base) == VAR_DECL
- && DECL_ALIGN (base) >= TYPE_ALIGN (vectype)));
-
/* If this is a backward running DR then first access in the larger
vectype actually is N-1 elements before the address in the DR.
Adjust misalign accordingly. */
}
free (LOOP_VINFO_BBS (loop_vinfo));
- free_data_refs (LOOP_VINFO_DATAREFS (loop_vinfo));
+ vect_destroy_datarefs (loop_vinfo, NULL);
free_dependence_relations (LOOP_VINFO_DDRS (loop_vinfo));
LOOP_VINFO_LOOP_NEST (loop_vinfo).release ();
LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo).release ();
free_stmt_vec_info (stmt);
}
- free_data_refs (BB_VINFO_DATAREFS (bb_vinfo));
+ vect_destroy_datarefs (NULL, bb_vinfo);
free_dependence_relations (BB_VINFO_DDRS (bb_vinfo));
BB_VINFO_GROUPED_STORES (bb_vinfo).release ();
slp_instances = BB_VINFO_SLP_INSTANCES (bb_vinfo);
return true;
}
+/* A helper function to ensure data reference DR's base alignment
+ for STMT_INFO. */
+
+static void
+ensure_base_align (stmt_vec_info stmt_info, struct data_reference *dr)
+{
+ if (!dr->aux)
+ return;
+
+ if (((dataref_aux *)dr->aux)->base_misaligned)
+ {
+ tree vectype = STMT_VINFO_VECTYPE (stmt_info);
+ tree base_decl = ((dataref_aux *)dr->aux)->base_decl;
+
+ DECL_ALIGN (base_decl) = TYPE_ALIGN (vectype);
+ DECL_USER_ALIGN (base_decl) = 1;
+ ((dataref_aux *)dr->aux)->base_misaligned = false;
+ }
+}
+
/* Function vectorizable_store.
static bool
vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
- slp_tree slp_node)
+ slp_tree slp_node)
{
tree scalar_dest;
tree data_ref;
/** Transform. **/
+ ensure_base_align (stmt_info, dr);
+
if (grouped_store)
{
first_dr = STMT_VINFO_DATA_REF (vinfo_for_stmt (first_stmt));
static bool
vectorizable_load (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
- slp_tree slp_node, slp_instance slp_node_instance)
+ slp_tree slp_node, slp_instance slp_node_instance)
{
tree scalar_dest;
tree vec_dest = NULL;
struct loop *loop = NULL;
struct loop *containing_loop = (gimple_bb (stmt))->loop_father;
bool nested_in_vect_loop = false;
- struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info), *first_dr;
+ struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info), *first_dr = NULL;
tree vectype = STMT_VINFO_VECTYPE (stmt_info);
tree elem_type;
tree new_temp;
/** Transform. **/
+ ensure_base_align (stmt_info, dr);
+
if (STMT_VINFO_GATHER_P (stmt_info))
{
tree vec_oprnd0 = NULL_TREE, op;
#include "tree-pass.h"
#include "hash-table.h"
#include "tree-ssa-propagate.h"
+#include "dbgcnt.h"
/* Loop or bb location. */
LOC vect_location;
}
}
\f
+/* A helper function to free data refs. */
+
+void
+vect_destroy_datarefs (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo)
+{
+ vec<data_reference_p> datarefs;
+ struct data_reference *dr;
+ unsigned int i;
+
+ if (loop_vinfo)
+ datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
+ else
+ datarefs = BB_VINFO_DATAREFS (bb_vinfo);
+
+ FOR_EACH_VEC_ELT (datarefs, i, dr)
+ if (dr->aux)
+ {
+ free (dr->aux);
+ dr->aux = NULL;
+ }
+
+ free_data_refs (datarefs);
+}
+
+
/* Function vectorize_loops.
Entry point to loop vectorization phase. */
if (!loop_vinfo || !LOOP_VINFO_VECTORIZABLE_P (loop_vinfo))
continue;
+ if (!dbg_cnt (vect_loop))
+ break;
+
if (LOCATION_LOCUS (vect_location) != UNKNOWN_LOC
&& dump_enabled_p ())
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
if (vect_slp_analyze_bb (bb))
{
+ if (!dbg_cnt (vect_slp))
+ break;
+
vect_slp_transform_bb (bb);
if (dump_enabled_p ())
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
#define PURE_SLP_STMT(S) ((S)->slp_type == pure_slp)
#define STMT_SLP_TYPE(S) (S)->slp_type
+struct dataref_aux {
+ tree base_decl;
+ bool base_misaligned;
+ int misalignment;
+};
+
#define VECT_MAX_COST 1000
/* The maximum number of intermediate steps required in multi-step type
/*-----------------------------------------------------------------*/
/* Info on data references alignment. */
/*-----------------------------------------------------------------*/
+inline void
+set_dr_misalignment (struct data_reference *dr, int val)
+{
+ dataref_aux *data_aux = (dataref_aux *) dr->aux;
+
+ if (!data_aux)
+ {
+ data_aux = XCNEW (dataref_aux);
+ dr->aux = data_aux;
+ }
+
+ data_aux->misalignment = val;
+}
+
+inline int
+dr_misalignment (struct data_reference *dr)
+{
+ gcc_assert (dr->aux);
+ return ((dataref_aux *) dr->aux)->misalignment;
+}
/* Reflects actual alignment of first access in the vectorized loop,
taking into account peeling/versioning if applied. */
-#define DR_MISALIGNMENT(DR) ((int) (size_t) (DR)->aux)
-#define SET_DR_MISALIGNMENT(DR, VAL) ((DR)->aux = (void *) (size_t) (VAL))
+#define DR_MISALIGNMENT(DR) dr_misalignment (DR)
+#define SET_DR_MISALIGNMENT(DR, VAL) set_dr_misalignment (DR, VAL)
/* Return TRUE if the data access is aligned, and FALSE otherwise. */
/* In tree-vectorizer.c. */
unsigned vectorize_loops (void);
+void vect_destroy_datarefs (loop_vec_info, bb_vec_info);
#endif /* GCC_TREE_VECTORIZER_H */