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.
(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:
--- /dev/null
+/* { 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);
+ }
+}