We have to watch out for vectorized stmt insert locations if the
def from the last stmt alters control flow. We constrain region
building so we know the def is outside of the current region
and thus we can insert at the region start point.
2022-05-02 Richard Biener <rguenther@suse.de>
PR tree-optimization/105437
* tree-vect-slp.cc (vect_schedule_slp_node): Handle the
case where last_stmt alters control flow.
* g++.dg/vect/pr105437.cc: New testcase.
--- /dev/null
+// { dg-do compile }
+
+struct ControlClass
+{
+ virtual ~ControlClass();
+
+ int Width;
+ int Height;
+ unsigned IsToRepaint : 1;
+};
+
+struct SelectClass : ControlClass
+{
+ SelectClass(void);
+};
+
+int Non_Folded_Value();
+
+SelectClass::SelectClass(void)
+{
+ int factor = Non_Folded_Value();
+ Width = 32 << factor;
+ Height = 24 << factor;
+}
gcc_assert (seen_vector_def);
si = gsi_after_labels (as_a <bb_vec_info> (vinfo)->bbs[0]);
}
+ else if (is_ctrl_altering_stmt (last_stmt))
+ {
+ /* We split regions to vectorize at control altering stmts
+ with a definition so this must be an external which
+ we can insert at the start of the region. */
+ si = gsi_after_labels (as_a <bb_vec_info> (vinfo)->bbs[0]);
+ }
else if (is_a <bb_vec_info> (vinfo)
&& gimple_bb (last_stmt) != gimple_bb (stmt_info->stmt)
&& gimple_could_trap_p (stmt_info->stmt))