slp_instance instance;
int i;
poly_uint64 min_vf = 2;
+ bool first_time_p = shared->datarefs.is_empty ();
/* The first group of checks is independent of the vector size. */
fatal = true;
return NULL;
BB_VINFO_DATAREFS (bb_vinfo) = datarefs;
- bb_vinfo->shared->save_datarefs ();
+ if (first_time_p)
+ bb_vinfo->shared->save_datarefs ();
+ else
+ bb_vinfo->shared->check_datarefs ();
/* Analyze the data references. */
return bb_vinfo;
}
+/* Subroutine of vect_slp_bb. Try to vectorize the statements between
+ REGION_BEGIN (inclusive) and REGION_END (exclusive), returning true
+ on success. The region has N_STMTS statements and has the datarefs
+ given by DATAREFS. */
-/* Main entry for the BB vectorizer. Analyze and transform BB, returns
- true if anything in the basic-block was vectorized. */
-
-bool
-vect_slp_bb (basic_block bb)
+static bool
+vect_slp_bb_region (gimple_stmt_iterator region_begin,
+ gimple_stmt_iterator region_end,
+ vec<data_reference_p> datarefs,
+ unsigned int n_stmts)
{
bb_vec_info bb_vinfo;
- gimple_stmt_iterator gsi;
- bool any_vectorized = false;
auto_vector_sizes vector_sizes;
/* Autodetect first vector size we try. */
targetm.vectorize.autovectorize_vector_sizes (&vector_sizes, false);
unsigned int next_size = 0;
- gsi = gsi_start_bb (bb);
+ vec_info_shared shared;
poly_uint64 autodetected_vector_size = 0;
while (1)
{
- if (gsi_end_p (gsi))
- break;
-
- gimple_stmt_iterator region_begin = gsi;
- vec<data_reference_p> datarefs = vNULL;
- int insns = 0;
-
- for (; !gsi_end_p (gsi); gsi_next (&gsi))
- {
- gimple *stmt = gsi_stmt (gsi);
- if (is_gimple_debug (stmt))
- continue;
- insns++;
-
- if (gimple_location (stmt) != UNKNOWN_LOCATION)
- vect_location = stmt;
-
- if (!vect_find_stmt_data_reference (NULL, stmt, &datarefs))
- break;
- }
-
- /* Skip leading unhandled stmts. */
- if (gsi_stmt (region_begin) == gsi_stmt (gsi))
- {
- gsi_next (&gsi);
- continue;
- }
-
- gimple_stmt_iterator region_end = gsi;
-
bool vectorized = false;
bool fatal = false;
- vec_info_shared shared;
bb_vinfo = vect_slp_analyze_bb_1 (region_begin, region_end,
- datarefs, insns, fatal, &shared);
+ datarefs, n_stmts, fatal, &shared);
if (bb_vinfo
&& dbg_cnt (vect_slp))
{
}
delete bb_vinfo;
- any_vectorized |= vectorized;
-
if (next_size == 0)
autodetected_vector_size = current_vector_size;
/* If vect_slp_analyze_bb_1 signaled that analysis for all
vector sizes will fail do not bother iterating. */
|| fatal)
+ return vectorized;
+
+ /* Try the next biggest vector size. */
+ current_vector_size = vector_sizes[next_size++];
+ if (dump_enabled_p ())
{
- if (gsi_end_p (region_end))
- break;
+ dump_printf_loc (MSG_NOTE, vect_location,
+ "***** Re-trying analysis with "
+ "vector size ");
+ dump_dec (MSG_NOTE, current_vector_size);
+ dump_printf (MSG_NOTE, "\n");
+ }
+ }
+}
- /* Skip the unhandled stmt. */
- gsi_next (&gsi);
+/* Main entry for the BB vectorizer. Analyze and transform BB, returns
+ true if anything in the basic-block was vectorized. */
- /* And reset vector sizes. */
- current_vector_size = 0;
- next_size = 0;
- }
- else
+bool
+vect_slp_bb (basic_block bb)
+{
+ gimple_stmt_iterator gsi;
+ bool any_vectorized = false;
+
+ gsi = gsi_start_bb (bb);
+ while (!gsi_end_p (gsi))
+ {
+ gimple_stmt_iterator region_begin = gsi;
+ vec<data_reference_p> datarefs = vNULL;
+ int insns = 0;
+
+ for (; !gsi_end_p (gsi); gsi_next (&gsi))
{
- /* Try the next biggest vector size. */
- current_vector_size = vector_sizes[next_size++];
- if (dump_enabled_p ())
- {
- dump_printf_loc (MSG_NOTE, vect_location,
- "***** Re-trying analysis with "
- "vector size ");
- dump_dec (MSG_NOTE, current_vector_size);
- dump_printf (MSG_NOTE, "\n");
- }
+ gimple *stmt = gsi_stmt (gsi);
+ if (is_gimple_debug (stmt))
+ continue;
+ insns++;
+
+ if (gimple_location (stmt) != UNKNOWN_LOCATION)
+ vect_location = stmt;
+
+ if (!vect_find_stmt_data_reference (NULL, stmt, &datarefs))
+ break;
+ }
- /* Start over. */
- gsi = region_begin;
+ /* Skip leading unhandled stmts. */
+ if (gsi_stmt (region_begin) == gsi_stmt (gsi))
+ {
+ gsi_next (&gsi);
+ continue;
}
+
+ gimple_stmt_iterator region_end = gsi;
+
+ if (vect_slp_bb_region (region_begin, region_end, datarefs, insns))
+ any_vectorized = true;
+
+ if (gsi_end_p (region_end))
+ break;
+
+ /* Skip the unhandled stmt. */
+ gsi_next (&gsi);
}
return any_vectorized;