As mentioned in the PR, we need to clean up orphan vector comparisons
that tend to happen be gimplification of VEC_COND_EXPR.
I've done that easily in expand_vector_comparison where I add these
to a bitmap used in simple DCE.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
gcc/ChangeLog:
PR tree-optimization/96128
* tree-vect-generic.c (expand_vector_comparison): Remove vector
comparisons that don't have a usage.
gcc/testsuite/ChangeLog:
PR tree-optimization/96128
* gcc.target/s390/vector/pr96128.c: New test.
---
.../gcc.target/s390/vector/pr96128.c | 35 +++++++++++++++++++
gcc/tree-vect-generic.c | 4 ++-
2 files changed, 38 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.target/s390/vector/pr96128.c
diff --git a/gcc/testsuite/gcc.target/s390/vector/pr96128.c
b/gcc/testsuite/gcc.target/s390/vector/pr96128.c
new file mode 100644
index 00000000000..20abe5e515c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/vector/pr96128.c
@@ -0,0 +1,35 @@
+/* PR tree-optimization/96128 */
+/* { dg-options "-march=z13" } */
+
+#define B_TEST(TYPE) { TYPE v __attribute__((vector_size(16))); (void)((v < v)
< v); }
+#ifdef __cplusplus
+#define T_TEST(TYPE) { TYPE s; TYPE v __attribute__((vector_size(16)));
__typeof((v<v)[0]) iv __attribute__((vector_size(16))); (void)((iv ? s : s) <
v); }
+#else
+#define T_TEST(TYPE)
+#endif
+#define T(TYPE) B_TEST(TYPE) T_TEST(TYPE)
+#ifdef __SIZEOF_INT128__
+#define SIZEOF_MAXINT __SIZEOF_INT128__
+#else
+#define SIZEOF_MAXINT __SIZEOF_LONG_LONG__
+#endif
+
+void f ()
+{
+ T(short)
+ T(int)
+ T(long)
+ T(long long)
+
+ T_TEST(float)
+ T_TEST(double)
+ /* Avoid trouble with non-power-of-two sizes.
+ Also avoid trouble with long double larger than integral types. */
+#if !defined(__i386__) && !defined(__x86_64__) && !defined(__m68k__) \
+ && !defined(__ia64__) && !defined(__hppa__) \
+ && (__SIZEOF_LONG_DOUBLE__ & (__SIZEOF_LONG_DOUBLE__ - 1)) == 0 \
+ && __SIZEOF_LONG_DOUBLE__ <= 16 \
+ && __SIZEOF_LONG_DOUBLE__ <= SIZEOF_MAXINT
+ T_TEST(long double)
+#endif
+}
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index f8bd26f2156..636104dea13 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -415,7 +415,9 @@ expand_vector_comparison (gimple_stmt_iterator *gsi, tree
type, tree op0,
}
}
- if (!uses.is_empty () && vec_cond_expr_only)
+ if (uses.is_empty ())
+ bitmap_set_bit (dce_ssa_names, SSA_NAME_VERSION (lhs));
+ else if (vec_cond_expr_only)
return NULL_TREE;
tree t;
--
2.27.0