/* Loop Vectorization
- Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
Contributed by Dorit Naishlos <dorit@il.ibm.com>
This file is part of GCC.
#define LOOP_VINFO_MAY_MISALIGN_STMTS(L) (L)->may_misalign_stmts
#define LOOP_VINFO_LOC(L) (L)->loop_line_number
+#define NITERS_KNOWN_P(n) \
+(host_integerp ((n),0) \
+&& TREE_INT_CST_LOW ((n)) > 0)
+
#define LOOP_VINFO_NITERS_KNOWN_P(L) \
-(host_integerp ((L)->num_iters,0) \
-&& TREE_INT_CST_LOW ((L)->num_iters) > 0)
+NITERS_KNOWN_P((L)->num_iters)
/*-----------------------------------------------------------------*/
/* Info on vectorized defs. */
assignment_vec_info_type,
condition_vec_info_type,
reduc_vec_info_type,
+ induc_vec_info_type,
type_promotion_vec_info_type,
- type_demotion_vec_info_type
+ type_demotion_vec_info_type,
+ type_conversion_vec_info_type
};
/* Indicates whether/how a variable is used in the loop. */
enum vect_relevant {
vect_unused_in_loop = 0,
+
+ /* defs that feed computations that end up (only) in a reduction. These
+ defs may be used by non-reduction stmts, but eventually, any
+ computations/values that are affected by these defs are used to compute
+ a reduction (i.e. don't get stored to memory, for example). We use this
+ to identify computations that we can change the order in which they are
+ computed. */
vect_used_by_reduction,
+
vect_used_in_loop
};
/* In case that two or more stmts share data-ref, this is the pointer to the
previously detected stmt with the same dr. */
tree same_dr_stmt;
+ /* For loads only, if there is a store with the same location, this field is
+ TRUE. */
+ bool read_write_dep;
+
+ /* Vectorization costs associated with statement. */
+ struct
+ {
+ int outside_of_loop; /* Statements generated outside loop. */
+ int inside_of_loop; /* Statements generated inside loop. */
+ } cost;
} *stmt_vec_info;
/* Access Functions. */
#define STMT_VINFO_DR_GROUP_STORE_COUNT(S) (S)->store_count
#define STMT_VINFO_DR_GROUP_GAP(S) (S)->gap
#define STMT_VINFO_DR_GROUP_SAME_DR_STMT(S)(S)->same_dr_stmt
+#define STMT_VINFO_DR_GROUP_READ_WRITE_DEPENDENCE(S) (S)->read_write_dep
#define DR_GROUP_FIRST_DR(S) (S)->first_dr
#define DR_GROUP_NEXT_DR(S) (S)->next_dr
#define DR_GROUP_STORE_COUNT(S) (S)->store_count
#define DR_GROUP_GAP(S) (S)->gap
#define DR_GROUP_SAME_DR_STMT(S) (S)->same_dr_stmt
+#define DR_GROUP_READ_WRITE_DEPENDENCE(S) (S)->read_write_dep
#define STMT_VINFO_RELEVANT_P(S) ((S)->relevant != vect_unused_in_loop)
+#define STMT_VINFO_OUTSIDE_OF_LOOP_COST(S) (S)->cost.outside_of_loop
+#define STMT_VINFO_INSIDE_OF_LOOP_COST(S) (S)->cost.inside_of_loop
+
+/* These are some defines for the initial implementation of the vectorizer's
+ cost model. These will later be target specific hooks. */
+
+/* Cost of conditional branch. */
+#ifndef TARG_COND_BRANCH_COST
+#define TARG_COND_BRANCH_COST 3
+#endif
+
+/* Cost of any vector operation, excluding load, store or vector to scalar
+ operation. */
+#ifndef TARG_VEC_STMT_COST
+#define TARG_VEC_STMT_COST 1
+#endif
+
+/* Cost of vector to scalar operation. */
+#ifndef TARG_VEC_TO_SCALAR_COST
+#define TARG_VEC_TO_SCALAR_COST 1
+#endif
+
+/* Cost of aligned vector load. */
+#ifndef TARG_VEC_LOAD_COST
+#define TARG_VEC_LOAD_COST 1
+#endif
+
+/* Cost of misaligned vector load. */
+#ifndef TARG_VEC_UNALIGNED_LOAD_COST
+#define TARG_VEC_UNALIGNED_LOAD_COST 2
+#endif
+
+/* Cost of vector store. */
+#ifndef TARG_VEC_STORE_COST
+#define TARG_VEC_STORE_COST 1
+#endif
static inline void set_stmt_info (stmt_ann_t ann, stmt_vec_info stmt_info);
static inline stmt_vec_info vinfo_for_stmt (tree stmt);
return ann ? (stmt_vec_info) ann->common.aux : NULL;
}
+static inline bool
+is_pattern_stmt_p (stmt_vec_info stmt_info)
+{
+ tree related_stmt;
+ stmt_vec_info related_stmt_info;
+
+ related_stmt = STMT_VINFO_RELATED_STMT (stmt_info);
+ if (related_stmt
+ && (related_stmt_info = vinfo_for_stmt (related_stmt))
+ && STMT_VINFO_IN_PATTERN_P (related_stmt_info))
+ return true;
+
+ return false;
+}
+
/*-----------------------------------------------------------------*/
/* Info on data references alignment. */
/*-----------------------------------------------------------------*/
/* Reflects actual alignment of first access in the vectorized loop,
taking into account peeling/versioning if applied. */
-#define DR_MISALIGNMENT(DR) (DR)->aux
+#define DR_MISALIGNMENT(DR) ((int) (size_t) (DR)->aux)
+#define SET_DR_MISALIGNMENT(DR, VAL) ((DR)->aux = (void *) (size_t) (VAL))
static inline bool
aligned_access_p (struct data_reference *data_ref_info)
return (DR_MISALIGNMENT (data_ref_info) != -1);
}
-/* Perform signed modulo, always returning a non-negative value. */
-#define VECT_SMODULO(x,y) ((x) % (y) < 0 ? ((x) % (y) + (y)) : (x) % (y))
-
/* vect_dump will be set to stderr or dump_file if exist. */
extern FILE *vect_dump;
extern enum verbosity_levels vect_verbosity_level;
-/* Number of loops, at the beginning of vectorization. */
-extern unsigned int vect_loops_num;
-
/* Bitmap of virtual variables to be renamed. */
-extern bitmap vect_vnames_to_rename;
+extern bitmap vect_memsyms_to_rename;
/*-----------------------------------------------------------------*/
/* Function prototypes. */
divide by the vectorization factor, and to peel the first few iterations
to force the alignment of data references in the loop. */
extern struct loop *slpeel_tree_peel_loop_to_edge
- (struct loop *, edge, tree, tree, bool);
+ (struct loop *, edge, tree, tree, bool, unsigned int);
extern void slpeel_make_loop_iterate_ntimes (struct loop *, tree);
extern bool slpeel_can_duplicate_loop_p (struct loop *, edge);
#ifdef ENABLE_CHECKING
extern bool reduction_code_for_scalar_code (enum tree_code, enum tree_code *);
extern bool supportable_widening_operation (enum tree_code, tree, tree,
tree *, tree *, enum tree_code *, enum tree_code *);
+extern bool supportable_narrowing_operation (enum tree_code, tree, tree,
+ enum tree_code *);
+
/* Creation and deletion of loop and stmt info structs. */
extern loop_vec_info new_loop_vec_info (struct loop *loop);
extern void destroy_loop_vec_info (loop_vec_info);
extern bool vectorizable_operation (tree, block_stmt_iterator *, tree *);
extern bool vectorizable_type_promotion (tree, block_stmt_iterator *, tree *);
extern bool vectorizable_type_demotion (tree, block_stmt_iterator *, tree *);
+extern bool vectorizable_conversion (tree, block_stmt_iterator *,
+ tree *);
extern bool vectorizable_assignment (tree, block_stmt_iterator *, tree *);
+extern tree vectorizable_function (tree, tree, tree);
extern bool vectorizable_call (tree, block_stmt_iterator *, tree *);
extern bool vectorizable_condition (tree, block_stmt_iterator *, tree *);
extern bool vectorizable_live_operation (tree, block_stmt_iterator *, tree *);
extern bool vectorizable_reduction (tree, block_stmt_iterator *, tree *);
+extern bool vectorizable_induction (tree, block_stmt_iterator *, tree *);
+extern int vect_estimate_min_profitable_iters (loop_vec_info);
/* Driver for transformation stage. */
extern void vect_transform_loop (loop_vec_info);