Esempio n. 1
0
unsigned
vectorize_loops (void)
{
  unsigned int i;
  unsigned int num_vectorized_loops = 0;
  unsigned int vect_loops_num;
  loop_iterator li;
  struct loop *loop;

  vect_loops_num = number_of_loops ();

  /* Bail out if there are no loops.  */
  if (vect_loops_num <= 1)
    return 0;

  init_stmt_vec_info_vec ();

  /*  ----------- Analyze loops. -----------  */

  /* If some loop was duplicated, it gets bigger number
     than all previously defined loops.  This fact allows us to run
     only over initial loops skipping newly generated ones.  */
  FOR_EACH_LOOP (li, loop, 0)
    if (optimize_loop_nest_for_speed_p (loop))
      {
	loop_vec_info loop_vinfo;
	vect_location = find_loop_location (loop);
        if (LOCATION_LOCUS (vect_location) != UNKNOWN_LOC
	    && dump_enabled_p ())
	  dump_printf (MSG_ALL, "\nAnalyzing loop at %s:%d\n",
                       LOC_FILE (vect_location), LOC_LINE (vect_location));

	loop_vinfo = vect_analyze_loop (loop);
	loop->aux = loop_vinfo;

	if (!loop_vinfo || !LOOP_VINFO_VECTORIZABLE_P (loop_vinfo))
	  continue;

        if (LOCATION_LOCUS (vect_location) != UNKNOWN_LOC
	    && dump_enabled_p ())
          dump_printf (MSG_ALL, "\n\nVectorizing loop at %s:%d\n",
                       LOC_FILE (vect_location), LOC_LINE (vect_location));
	vect_transform_loop (loop_vinfo);
	num_vectorized_loops++;
      }

  vect_location = UNKNOWN_LOC;

  statistics_counter_event (cfun, "Vectorized loops", num_vectorized_loops);
  if (dump_enabled_p ()
      || (num_vectorized_loops > 0 && dump_enabled_p ()))
    dump_printf_loc (MSG_ALL, vect_location,
                     "vectorized %u loops in function.\n",
                     num_vectorized_loops);

  /*  ----------- Finalize. -----------  */

  for (i = 1; i < vect_loops_num; i++)
    {
      loop_vec_info loop_vinfo;

      loop = get_loop (i);
      if (!loop)
	continue;
      loop_vinfo = (loop_vec_info) loop->aux;
      destroy_loop_vec_info (loop_vinfo, true);
      loop->aux = NULL;
    }

  free_stmt_vec_info_vec ();

  return num_vectorized_loops > 0 ? TODO_cleanup_cfg : 0;
}
Esempio n. 2
0
unsigned
vectorize_loops (void)
{
  unsigned int i;
  unsigned int num_vectorized_loops = 0;
  unsigned int vect_loops_num;
  loop_iterator li;
  struct loop *loop;

  vect_loops_num = number_of_loops ();

  /* Bail out if there are no loops.  */
  if (vect_loops_num <= 1)
    return 0;

  /* Fix the verbosity level if not defined explicitly by the user.  */
  vect_set_dump_settings (false);

  init_stmt_vec_info_vec ();

  /*  ----------- Analyze loops. -----------  */

  /* If some loop was duplicated, it gets bigger number
     than all previously defined loops.  This fact allows us to run
     only over initial loops skipping newly generated ones.  */
  FOR_EACH_LOOP (li, loop, 0)
    if (optimize_loop_nest_for_speed_p (loop))
      {
	loop_vec_info loop_vinfo;

	vect_location = find_loop_location (loop);
        if (vect_location != UNKNOWN_LOC
            && vect_verbosity_level > REPORT_NONE)
	  fprintf (vect_dump, "\nAnalyzing loop at %s:%d\n",
            LOC_FILE (vect_location), LOC_LINE (vect_location));

	loop_vinfo = vect_analyze_loop (loop);
	loop->aux = loop_vinfo;

	if (!loop_vinfo || !LOOP_VINFO_VECTORIZABLE_P (loop_vinfo))
	  continue;

        if (vect_location != UNKNOWN_LOC
            && vect_verbosity_level > REPORT_NONE)
          fprintf (vect_dump, "\n\nVectorizing loop at %s:%d\n",
            LOC_FILE (vect_location), LOC_LINE (vect_location));

	vect_transform_loop (loop_vinfo);
	num_vectorized_loops++;
      }

  vect_location = UNKNOWN_LOC;

  statistics_counter_event (cfun, "Vectorized loops", num_vectorized_loops);
  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)
      || (num_vectorized_loops > 0
	  && vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS)))
    fprintf (vect_dump, "vectorized %u loops in function.\n",
	     num_vectorized_loops);

  /*  ----------- Finalize. -----------  */

  mark_sym_for_renaming (gimple_vop (cfun));

  for (i = 1; i < vect_loops_num; i++)
    {
      loop_vec_info loop_vinfo;

      loop = get_loop (i);
      if (!loop)
	continue;
      loop_vinfo = (loop_vec_info) loop->aux;
      destroy_loop_vec_info (loop_vinfo, true);
      loop->aux = NULL;
    }

  free_stmt_vec_info_vec ();

  return num_vectorized_loops > 0 ? TODO_cleanup_cfg : 0;
}
Esempio n. 3
0
unsigned
vectorize_loops (void)
{
    unsigned int i;
    unsigned int num_vectorized_loops = 0;
    unsigned int vect_loops_num;
    loop_iterator li;
    struct loop *loop;

    vect_loops_num = number_of_loops (cfun);

    /* Bail out if there are no loops.  */
    if (vect_loops_num <= 1)
        return 0;

    init_stmt_vec_info_vec ();

    /*  ----------- Analyze loops. -----------  */

    /* If some loop was duplicated, it gets bigger number
       than all previously defined loops.  This fact allows us to run
       only over initial loops skipping newly generated ones.  */
    FOR_EACH_LOOP (li, loop, 0)
    if (optimize_loop_nest_for_speed_p (loop))
    {
        loop_vec_info loop_vinfo;
        vect_location = find_loop_location (loop);
        if (LOCATION_LOCUS (vect_location) != UNKNOWN_LOC
                && dump_enabled_p ())
            dump_printf (MSG_NOTE, "\nAnalyzing loop at %s:%d\n",
                         LOC_FILE (vect_location), LOC_LINE (vect_location));

        loop_vinfo = vect_analyze_loop (loop);
        loop->aux = loop_vinfo;

        if (!loop_vinfo || !LOOP_VINFO_VECTORIZABLE_P (loop_vinfo))
            continue;

        if (LOCATION_LOCUS (vect_location) != UNKNOWN_LOC
                && dump_enabled_p ())
            dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
                             "Vectorized loop\n");
        vect_transform_loop (loop_vinfo);
        num_vectorized_loops++;
    }

    vect_location = UNKNOWN_LOC;

    statistics_counter_event (cfun, "Vectorized loops", num_vectorized_loops);
    if (dump_enabled_p ()
            || (num_vectorized_loops > 0 && dump_enabled_p ()))
        dump_printf_loc (MSG_NOTE, vect_location,
                         "vectorized %u loops in function.\n",
                         num_vectorized_loops);

    /*  ----------- Finalize. -----------  */

    for (i = 1; i < vect_loops_num; i++)
    {
        loop_vec_info loop_vinfo;

        loop = get_loop (cfun, i);
        if (!loop)
            continue;
        loop_vinfo = (loop_vec_info) loop->aux;
        destroy_loop_vec_info (loop_vinfo, true);
        loop->aux = NULL;
    }

    free_stmt_vec_info_vec ();

    if (num_vectorized_loops > 0)
    {
        /* If we vectorized any loop only virtual SSA form needs to be updated.
        ???  Also while we try hard to update loop-closed SSA form we fail
         to properly do this in some corner-cases (see PR56286).  */
        rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa_only_virtuals);
        return TODO_cleanup_cfg;
    }

    return 0;
}