aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-09-24 10:14:33 +0200
committerRichard Biener <rguenther@suse.de>2020-09-24 10:20:41 +0200
commit10843f8303509fcba880c6c05c08e4b4ccd24f36 (patch)
treef31b1e91b04fde83788a442b217e4ec6db7b5f3d /gcc
parent7e437162001f258c8db4eae25da3bca812dd557a (diff)
downloadgcc-10843f8303509fcba880c6c05c08e4b4ccd24f36.zip
gcc-10843f8303509fcba880c6c05c08e4b4ccd24f36.tar.gz
gcc-10843f8303509fcba880c6c05c08e4b4ccd24f36.tar.bz2
tree-optimization/97085 - fold some trivial bool vector ?:
The following aovids the ICE in the testcase by doing some additional simplification of VEC_COND_EXPRs for VECTOR_BOOLEAN_TYPE_P which we don't really expect, esp. when they are not classical vectors, thus AVX512 or SVE masks. 2020-09-24 Richard Biener <rguenther@suse.de> PR tree-optimization/97085 * match.pd (mask ? { false,..} : { true, ..} -> ~mask): New. * gcc.dg/vect/pr97085.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/match.pd11
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr97085.c13
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index 7d63bb9..e6dcdd0 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3521,6 +3521,17 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(if (optimize_vectors_before_lowering_p () && types_match (@0, @1))
(vec_cond (bit_and (bit_not @0) @1) @2 @3)))
+/* Canonicalize mask ? { 0, ... } : { -1, ...} to ~mask if the mask
+ types are compatible. */
+(simplify
+ (vec_cond @0 VECTOR_CST@1 VECTOR_CST@2)
+ (if (VECTOR_BOOLEAN_TYPE_P (type)
+ && types_match (type, TREE_TYPE (@0)))
+ (if (integer_zerop (@1) && integer_all_onesp (@2))
+ (bit_not @0)
+ (if (integer_all_onesp (@1) && integer_zerop (@2))
+ @0))))
+
/* Simplification moved from fold_cond_expr_with_comparison. It may also
be extended. */
/* This pattern implements two kinds simplification:
diff --git a/gcc/testsuite/gcc.dg/vect/pr97085.c b/gcc/testsuite/gcc.dg/vect/pr97085.c
new file mode 100644
index 0000000..ffde9f1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr97085.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-march=armv8.2-a+sve" { target aarch64-*-* } } */
+
+int a, b, c, d;
+short e, g;
+unsigned short f;
+void h() {
+ for (; d; d++) {
+ g = d;
+ e = b == 0 ? 1 : a % b;
+ c ^= (f = e) > (g == 5);
+ }
+}