Improve BB vectorization opt-info
Checks
Commit Message
The following makes us more correctly print the used vector size
when doing BB vectorization and also print all involved SLP graph
roots, not just the random one we ended up picking as leader.
In particular the last bit improves diffing opt-info between
different GCC revs but it also requires some testsuite adjustments.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
* tree-vect-slp.cc (vect_slp_region): Provide opt-info for all SLP
subgraph entries. Dump the used vector size based on the
SLP subgraph entry root vector type.
* g++.dg/vect/slp-pr87105.cc: Adjust.
* gcc.dg/vect/bb-slp-17.c: Likewise.
* gcc.dg/vect/bb-slp-20.c: Likewise.
* gcc.dg/vect/bb-slp-21.c: Likewise.
* gcc.dg/vect/bb-slp-22.c: Likewise.
* gcc.dg/vect/bb-slp-subgroups-2.c: Likewise.
---
gcc/testsuite/g++.dg/vect/slp-pr87105.cc | 2 +-
gcc/testsuite/gcc.dg/vect/bb-slp-17.c | 5 ++-
gcc/testsuite/gcc.dg/vect/bb-slp-20.c | 3 +-
gcc/testsuite/gcc.dg/vect/bb-slp-21.c | 3 +-
gcc/testsuite/gcc.dg/vect/bb-slp-22.c | 2 +-
.../gcc.dg/vect/bb-slp-subgroups-2.c | 2 +-
gcc/tree-vect-slp.cc | 37 ++++++++++++-------
7 files changed, 33 insertions(+), 21 deletions(-)
@@ -99,7 +99,7 @@ void quadBoundingBoxA(const Point bez[3], Box& bBox) noexcept {
// We should have if-converted everything down to straight-line code
// { dg-final { scan-tree-dump-times "<bb \[0-9\]+>" 1 "slp2" } }
-// { dg-final { scan-tree-dump-times "basic block part vectorized" 1 "slp2" { xfail { { ! vect_element_align } && { ! vect_hw_misalign } } } } }
+// { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 1 "slp2" { xfail { { ! vect_element_align } && { ! vect_hw_misalign } } } } }
// It's a bit awkward to detect that all stores were vectorized but the
// following more or less does the trick
// { dg-final { scan-tree-dump "vect_\[^\r\m\]* = MIN" "slp2" { xfail { { ! vect_element_align } && { ! vect_hw_misalign } } } } }
@@ -58,5 +58,6 @@ int main (void)
}
/* We need V2SI vector add support for the b[] vectorization, if we don't
- have that we might only see the store vectorized and thus 2 subgraphs. */
-/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target { vect_int_mult && vect64 } } } } */
+ have that we might only see the store vectorized. In any case we have
+ two subgraph entries. */
+/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" { target { vect_int_mult && vect64 } } } } */
@@ -63,6 +63,7 @@ int main (void)
return 0;
}
-/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target vect_int_mult } } } */
+/* { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 1 "slp2" { target vect_int_mult } } } */
+/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" { target vect_int_mult } } } */
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "slp2" { target vect_int_mult } } } */
@@ -63,6 +63,7 @@ int main (void)
return 0;
}
-/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" } } */
+/* { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 1 "slp2" } } */
+/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" } } */
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "slp2" } } */
@@ -63,5 +63,5 @@ int main (void)
return 0;
}
-/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" } } */
+/* { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 1 "slp2" } } */
/* { dg-final { scan-tree-dump "vectorizing SLP node starting from: _\[0-9\]+ = _\[0-9\]+ \\\* a0" "slp2" { target vect_int_mult } } } */
@@ -39,4 +39,4 @@ main (int argc, char **argv)
}
/* { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 1 "slp2" } } */
-/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" } } */
+/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" } } */
@@ -7574,25 +7574,34 @@ vect_slp_region (vec<basic_block> bbs, vec<data_reference_p> datarefs,
"using SLP\n");
vectorized = true;
+ /* Dump before scheduling as store vectorization will remove
+ the original stores and mess with the instance tree
+ so querying its location will eventually ICE. */
+ if (flag_checking)
+ for (slp_instance sub : instance->subgraph_entries)
+ gcc_assert (SLP_TREE_VECTYPE (SLP_INSTANCE_TREE (sub)));
+ unsigned HOST_WIDE_INT bytes;
+ if (dump_enabled_p ())
+ for (slp_instance sub : instance->subgraph_entries)
+ {
+ tree vtype = SLP_TREE_VECTYPE (SLP_INSTANCE_TREE (sub));
+ if (GET_MODE_SIZE (TYPE_MODE (vtype)).is_constant (&bytes))
+ dump_printf_loc (MSG_OPTIMIZED_LOCATIONS,
+ sub->location (),
+ "basic block part vectorized using %wu "
+ "byte vectors\n", bytes);
+ else
+ dump_printf_loc (MSG_OPTIMIZED_LOCATIONS,
+ sub->location (),
+ "basic block part vectorized using "
+ "variable length vectors\n");
+ }
+
dump_user_location_t saved_vect_location = vect_location;
vect_location = instance->location ();
vect_schedule_slp (bb_vinfo, instance->subgraph_entries);
- unsigned HOST_WIDE_INT bytes;
- if (dump_enabled_p ())
- {
- if (GET_MODE_SIZE
- (bb_vinfo->vector_mode).is_constant (&bytes))
- dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
- "basic block part vectorized using %wu "
- "byte vectors\n", bytes);
- else
- dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
- "basic block part vectorized using "
- "variable length vectors\n");
- }
-
vect_location = saved_vect_location;
}
}