diff options
Diffstat (limited to 'gcc/targhooks.c')
-rw-r--r-- | gcc/targhooks.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 5bbec5a..7d48bca 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -996,6 +996,64 @@ default_autovectorize_vector_sizes (void) return 0; } +/* By default, the cost model just accumulates the inside_loop costs for + a vectorized loop or block. So allocate an unsigned int, set it to + zero, and return its address. */ + +void * +default_init_cost (struct loop *loop_info ATTRIBUTE_UNUSED) +{ + unsigned *cost = XNEW (unsigned); + *cost = 0; + return cost; +} + +/* By default, the cost model looks up the cost of the given statement + kind and mode, multiplies it by the occurrence count, accumulates + it into the cost, and returns the cost added. */ + +unsigned +default_add_stmt_cost (void *data, int count, enum vect_cost_for_stmt kind, + struct _stmt_vec_info *stmt_info, int misalign) +{ + unsigned *cost = (unsigned *) data; + unsigned retval = 0; + + if (flag_vect_cost_model) + { + tree vectype = stmt_vectype (stmt_info); + int stmt_cost = default_builtin_vectorization_cost (kind, vectype, + misalign); + /* Statements in an inner loop relative to the loop being + vectorized are weighted more heavily. The value here is + arbitrary and could potentially be improved with analysis. */ + if (stmt_in_inner_loop_p (stmt_info)) + count *= 50; /* FIXME. */ + + retval = (unsigned) (count * stmt_cost); + *cost += retval; + } + + return retval; +} + +/* By default, the cost model just returns the accumulated + inside_loop cost. */ + +unsigned +default_finish_cost (void *data) +{ + return *((unsigned *) data); +} + +/* Free the cost data. */ + +void +default_destroy_cost_data (void *data) +{ + free (data); +} + /* Determine whether or not a pointer mode is valid. Assume defaults of ptr_mode or Pmode - can be overridden. */ bool |