This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC][PATCH] New Vectorizer APIs


Hi,

This patch introduces new vectorizer functions that could be called from 
other passes, 
allowing the caller to obtain information about the vectorizability of a 
loop, or the 
costs of vectorizing it vs not vectorizing it.

The APIs I implemented are:
1. loop_vectorizable_p  - tells whether the the loop is vectorizable.

2. get_min_prof_iters - returns minimum number of iterations 
for which vectorization is profitable

3. get_int_sv_costs -  given an integer value representing the number of 
iterations, 
this function returns two integer parameters representing the scalar cost 
and 
the vectorized cost for the loop.
 
4. get_tree_sv_costs -  like get_int_sv_costs, only the number of 
itreations is given as 
a tree (it could be a symbolic expr), and the return values (scalar and 
vector costs) 
are also exprs depending on the numebr of iterations argument.

We have a few ideas on potential passes that could benefit from using 
these APIs to make their decisions.
One of our ideas is complete loop unrolling that occurs before the 
vectorizer. 
The knowledge about the vectorizability and the profitability of 
vectorizing a 
certian loop could be taken into account in the unroller's decision 
mechanism.

Another  potantial user could be if conversion pass.
Any other suggestions are welcome.


In order to test the above functions, I created an artificial pass running 
before
the vectorizer, calling each one of the these functions.
For sanity checking, I ran tests with this pass enabled; bootstrap and 
testsuite 
passed successfully for c, c++ and Fortran (i386-Linux).

It is pretty straight forward, but here's what the main driver that I used
looks like:

bool
call_vect (void)
{
  struct loop *loop;
  loop_iterator li;
  int scalar_cost, vect_cost;
  tree t_scalar_cost, t_vect_cost;
  FILE *saved_vect_dump=NULL;
  if (vect_dump)
   {
    saved_vect_dump = vect_dump;
    vect_dump = NULL;
   }
  FOR_EACH_LOOP (li, loop, 0)
    {
        loop_vectorizable_p (loop);
        get_min_prof_iters (loop);
        get_int_sv_costs (loop, 10, &scalar_cost, &vect_cost);
        get_tree_sv_costs (loop, build_int_cst (NULL_TREE, 22), 
&t_scalar_cost, &t_vect_cost);
    }
  vect_dump = saved_vect_dump;
  return true;
}


Any comments or suggestions are welcome,
Thanks,
Razya

ChangeLog:

        * tree-vectorizer.h (costs, sv_result_costs): New structures.
        (vect_performance_improvement, vect_performance_improvement_2, 
        loop_vectorizable_p, get_min_prof_iters, get_int_sv_costs, 
        get_tree_sv_costs): Declare new functions. 
        * tree-vect-analyze.c (compute_iterations, cost_iterations): New 
variables.
        (loop_vectorizable_p, get_min_prof_iters, get_int_sv_costs, 
        get_tree_sv_costs, vect_loop_niters): New functions.
        (vect_compute_loop_niters): New function, replacing 
vect_get_loop_niters.
        (vect_get_loop_niters): Remove.
        (vect_analyze_loop_form): Use compute_iterations.
        * tree-vect-transform.c (scalar_vect_cost): New structure.
        (vect_set_cost_parameters): New function.
        (vect_estimate_min_profitable_iters): Use vect_set_cost_parameters 

        to compute the cost parameters.
        (vect_performance_improvement, vect_performance_improvement_2): 
New functions.

Attachment: vect_cm_api.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]