summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-05-25 10:36:39 +0200
committerRichard Biener <rguenther@suse.de>2020-05-25 13:12:20 +0200
commitc0e27f72358794692e367363940c6383e9ad1e45 (patch)
treed6d197914bff904677925e5257a14b2da108745a
parentd31694544d2d805151899ab0a0bc654767035ad6 (diff)
tree-optimization/95271 - fix bswap vectorization invariant SLP type
This properly updates invariant SLP nodes vector types for bswap vectorization. 2020-05-25 Richard Biener <rguenther@suse.de> PR tree-optimization/95271 * tree-vect-stmts.c (vectorizable_bswap): Update invariant SLP children vector type. (vectorizable_call): Pass down slp ops. * gcc.dg/vect/bb-slp-pr95271.c: New testcase.
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-pr95271.c19
-rw-r--r--gcc/tree-vect-stmts.c12
4 files changed, 42 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 38ca3ef863b..1e037dabe49 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2020-05-25 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/95271
+ * tree-vect-stmts.c (vectorizable_bswap): Update invariant SLP
+ children vector type.
+ (vectorizable_call): Pass down slp ops.
+
+2020-05-25 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/95297
* tree-vect-stmts.c (vectorizable_shift): For scalar_shift_arg
skip updating operand 1 vector type.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2ac873c4291..abe0f32be3e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2020-05-25 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/95271
+ * gcc.dg/vect/bb-slp-pr95271.c: New testcase.
+
+2020-05-25 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/95297
* g++.dg/vect/pr95297.cc: New testcase.
* g++.dg/vect/pr95290.cc: Likewise.
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr95271.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr95271.c
new file mode 100644
index 00000000000..2f235980405
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr95271.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-march=cooperlake" { target x86_64-*-* i?86-*-* } } */
+
+int a;
+struct b c;
+long d;
+struct b {
+ unsigned long address;
+ unsigned long e;
+};
+void f()
+{
+ d = (long)(&a)[0] << 56 | (long)((unsigned char *)&a)[1] << 48 |
+ (long)((unsigned char *)&a)[2] << 40 |
+ (long)((unsigned char *)&a)[3] << 32 |
+ (long)((unsigned char *)&a)[4] << 24 | ((unsigned char *)&a)[5] << 16 |
+ ((unsigned char *)&a)[6] << 8 | ((unsigned char *)&a)[7];
+ c.address = c.e = d;
+}
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index c3254926e22..76c7b995817 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -3009,6 +3009,7 @@ static bool
vectorizable_bswap (vec_info *vinfo,
stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
stmt_vec_info *vec_stmt, slp_tree slp_node,
+ slp_tree *slp_op,
tree vectype_in, stmt_vector_for_cost *cost_vec)
{
tree op, vectype;
@@ -3051,6 +3052,15 @@ vectorizable_bswap (vec_info *vinfo,
if (! vec_stmt)
{
+ if (slp_node
+ && !vect_maybe_update_slp_op_vectype (slp_op[0], vectype_in))
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "incompatible vector types for invariants\n");
+ return false;
+ }
+
STMT_VINFO_TYPE (stmt_info) = call_vec_info_type;
DUMP_VECT_SCOPE ("vectorizable_bswap");
if (! slp_node)
@@ -3377,7 +3387,7 @@ vectorizable_call (vec_info *vinfo,
|| gimple_call_builtin_p (stmt, BUILT_IN_BSWAP32)
|| gimple_call_builtin_p (stmt, BUILT_IN_BSWAP64)))
return vectorizable_bswap (vinfo, stmt_info, gsi, vec_stmt, slp_node,
- vectype_in, cost_vec);
+ slp_op, vectype_in, cost_vec);
else
{
if (dump_enabled_p ())