vectorizer: add _bb_vec_info::region_stmts and reverse_region_stmts
gcc/ChangeLog: * coretypes.h (struct iterator_range): New type. * tree-vect-patterns.c (vect_determine_precisions): Use range-based iterator. (vect_pattern_recog): Likewise. * tree-vect-slp.c (_bb_vec_info): Likewise. (_bb_vec_info::~_bb_vec_info): Likewise. (vect_slp_check_for_constructors): Likewise. * tree-vectorizer.h:Add new iterators and functions that use it.
This commit is contained in:
parent
bd0a89dcd8
commit
72cb486456
@ -363,6 +363,23 @@ struct kv_pair
|
||||
template<typename T1, typename T2>
|
||||
using first_type = T1;
|
||||
|
||||
/* Iterator pair used for a collection iteration with range-based loops. */
|
||||
|
||||
template<typename T>
|
||||
struct iterator_range
|
||||
{
|
||||
public:
|
||||
iterator_range (const T &begin, const T &end)
|
||||
: m_begin (begin), m_end (end) {}
|
||||
|
||||
T begin () const { return m_begin; }
|
||||
T end () const { return m_end; }
|
||||
|
||||
private:
|
||||
T m_begin;
|
||||
T m_end;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
struct _dont_use_rtx_here_;
|
||||
|
@ -5120,20 +5120,12 @@ vect_determine_precisions (vec_info *vinfo)
|
||||
else
|
||||
{
|
||||
bb_vec_info bb_vinfo = as_a <bb_vec_info> (vinfo);
|
||||
gimple_stmt_iterator si = bb_vinfo->region_end;
|
||||
gimple *stmt;
|
||||
do
|
||||
for (gimple *stmt : bb_vinfo->reverse_region_stmts ())
|
||||
{
|
||||
if (!gsi_stmt (si))
|
||||
si = gsi_last_bb (bb_vinfo->bb);
|
||||
else
|
||||
gsi_prev (&si);
|
||||
stmt = gsi_stmt (si);
|
||||
stmt_vec_info stmt_info = vinfo->lookup_stmt (stmt);
|
||||
if (stmt_info && STMT_VINFO_VECTORIZABLE (stmt_info))
|
||||
vect_determine_stmt_precisions (vinfo, stmt_info);
|
||||
}
|
||||
while (stmt != gsi_stmt (bb_vinfo->region_begin));
|
||||
}
|
||||
}
|
||||
|
||||
@ -5492,10 +5484,8 @@ vect_pattern_recog (vec_info *vinfo)
|
||||
else
|
||||
{
|
||||
bb_vec_info bb_vinfo = as_a <bb_vec_info> (vinfo);
|
||||
for (si = bb_vinfo->region_begin;
|
||||
gsi_stmt (si) != gsi_stmt (bb_vinfo->region_end); gsi_next (&si))
|
||||
for (gimple *stmt : bb_vinfo->region_stmts ())
|
||||
{
|
||||
gimple *stmt = gsi_stmt (si);
|
||||
stmt_vec_info stmt_info = bb_vinfo->lookup_stmt (stmt);
|
||||
if (!stmt_info || !STMT_VINFO_VECTORIZABLE (stmt_info))
|
||||
continue;
|
||||
|
@ -2588,12 +2588,8 @@ _bb_vec_info::_bb_vec_info (gimple_stmt_iterator region_begin_in,
|
||||
region_begin (region_begin_in),
|
||||
region_end (region_end_in)
|
||||
{
|
||||
gimple_stmt_iterator gsi;
|
||||
|
||||
for (gsi = region_begin; gsi_stmt (gsi) != gsi_stmt (region_end);
|
||||
gsi_next (&gsi))
|
||||
for (gimple *stmt : this->region_stmts ())
|
||||
{
|
||||
gimple *stmt = gsi_stmt (gsi);
|
||||
gimple_set_uid (stmt, 0);
|
||||
if (is_gimple_debug (stmt))
|
||||
continue;
|
||||
@ -2609,10 +2605,9 @@ _bb_vec_info::_bb_vec_info (gimple_stmt_iterator region_begin_in,
|
||||
|
||||
_bb_vec_info::~_bb_vec_info ()
|
||||
{
|
||||
for (gimple_stmt_iterator si = region_begin;
|
||||
gsi_stmt (si) != gsi_stmt (region_end); gsi_next (&si))
|
||||
for (gimple *stmt : this->region_stmts ())
|
||||
/* Reset region marker. */
|
||||
gimple_set_uid (gsi_stmt (si), -1);
|
||||
gimple_set_uid (stmt, -1);
|
||||
|
||||
bb->aux = NULL;
|
||||
}
|
||||
@ -3050,16 +3045,13 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo)
|
||||
static void
|
||||
vect_slp_check_for_constructors (bb_vec_info bb_vinfo)
|
||||
{
|
||||
gimple_stmt_iterator gsi;
|
||||
|
||||
for (gsi = bb_vinfo->region_begin;
|
||||
gsi_stmt (gsi) != gsi_stmt (bb_vinfo->region_end); gsi_next (&gsi))
|
||||
for (gimple *stmt : bb_vinfo->region_stmts ())
|
||||
{
|
||||
gassign *stmt = dyn_cast <gassign *> (gsi_stmt (gsi));
|
||||
if (!stmt || gimple_assign_rhs_code (stmt) != CONSTRUCTOR)
|
||||
gassign *assign = dyn_cast<gassign *> (stmt);
|
||||
if (!assign || gimple_assign_rhs_code (assign) != CONSTRUCTOR)
|
||||
continue;
|
||||
|
||||
tree rhs = gimple_assign_rhs1 (stmt);
|
||||
tree rhs = gimple_assign_rhs1 (assign);
|
||||
if (!VECTOR_TYPE_P (TREE_TYPE (rhs))
|
||||
|| maybe_ne (TYPE_VECTOR_SUBPARTS (TREE_TYPE (rhs)),
|
||||
CONSTRUCTOR_NELTS (rhs))
|
||||
@ -3067,7 +3059,7 @@ vect_slp_check_for_constructors (bb_vec_info bb_vinfo)
|
||||
|| uniform_vector_p (rhs))
|
||||
continue;
|
||||
|
||||
stmt_vec_info stmt_info = bb_vinfo->lookup_stmt (stmt);
|
||||
stmt_vec_info stmt_info = bb_vinfo->lookup_stmt (assign);
|
||||
BB_VINFO_GROUPED_STORES (bb_vinfo).safe_push (stmt_info);
|
||||
}
|
||||
}
|
||||
|
@ -792,9 +792,91 @@ loop_vec_info_for_loop (class loop *loop)
|
||||
typedef class _bb_vec_info : public vec_info
|
||||
{
|
||||
public:
|
||||
|
||||
/* GIMPLE statement iterator going from region_begin to region_end. */
|
||||
|
||||
struct const_iterator
|
||||
{
|
||||
const_iterator (gimple_stmt_iterator _gsi) : gsi (_gsi) {}
|
||||
|
||||
const const_iterator &
|
||||
operator++ ()
|
||||
{
|
||||
gsi_next (&gsi); return *this;
|
||||
}
|
||||
|
||||
gimple *operator* () const { return gsi_stmt (gsi); }
|
||||
|
||||
bool
|
||||
operator== (const const_iterator &other) const
|
||||
{
|
||||
return gsi_stmt (gsi) == gsi_stmt (other.gsi);
|
||||
}
|
||||
|
||||
bool
|
||||
operator!= (const const_iterator &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
gimple_stmt_iterator gsi;
|
||||
};
|
||||
|
||||
/* GIMPLE statement iterator going from region_end to region_begin. */
|
||||
|
||||
struct const_reverse_iterator
|
||||
{
|
||||
const_reverse_iterator (gimple_stmt_iterator _gsi) : gsi (_gsi) {}
|
||||
|
||||
const const_reverse_iterator &
|
||||
operator++ ()
|
||||
{
|
||||
gsi_prev (&gsi); return *this;
|
||||
}
|
||||
|
||||
gimple *operator* () const { return gsi_stmt (gsi); }
|
||||
|
||||
bool
|
||||
operator== (const const_reverse_iterator &other) const
|
||||
{
|
||||
return gsi_stmt (gsi) == gsi_stmt (other.gsi);
|
||||
}
|
||||
|
||||
bool
|
||||
operator!= (const const_reverse_iterator &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
gimple_stmt_iterator gsi;
|
||||
};
|
||||
|
||||
_bb_vec_info (gimple_stmt_iterator, gimple_stmt_iterator, vec_info_shared *);
|
||||
~_bb_vec_info ();
|
||||
|
||||
/* Returns iterator_range for range-based loop. */
|
||||
|
||||
iterator_range<const_iterator>
|
||||
region_stmts ()
|
||||
{
|
||||
return iterator_range<const_iterator> (region_begin, region_end);
|
||||
}
|
||||
|
||||
/* Returns iterator_range for range-based loop in a reverse order. */
|
||||
|
||||
iterator_range<const_reverse_iterator>
|
||||
reverse_region_stmts ()
|
||||
{
|
||||
const_reverse_iterator begin = region_end;
|
||||
if (*begin == NULL)
|
||||
begin = const_reverse_iterator (gsi_last_bb (region_end.bb));
|
||||
else
|
||||
++begin;
|
||||
|
||||
const_reverse_iterator end = region_begin;
|
||||
return iterator_range<const_reverse_iterator> (begin, ++end);
|
||||
}
|
||||
|
||||
basic_block bb;
|
||||
gimple_stmt_iterator region_begin;
|
||||
gimple_stmt_iterator region_end;
|
||||
|
Loading…
Reference in New Issue
Block a user