We fail to reject vectorizing of comparisons of non-mode precision
integer types. Those need to be dealt with via bitfield lowering
in ifcvt or pattern recognition.
Bootstrapped and tested on x86_64-unknown-linux-gnu.
OK?
Thanks,
Richard.
PR tree-optimization/127390
* tree-vect-stmts.cc (vectorizable_comparison_1): Reject
bit-precision integer comparisons.
* gcc.dg/vect/vect-pr127390.c: New testcase.
---
gcc/testsuite/gcc.dg/vect/vect-pr127390.c | 28 +++++++++++++++++++++++
gcc/tree-vect-stmts.cc | 7 ++++++
2 files changed, 35 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/vect/vect-pr127390.c
diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr127390.c
b/gcc/testsuite/gcc.dg/vect/vect-pr127390.c
new file mode 100644
index 00000000000..5f54c16f9c3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-pr127390.c
@@ -0,0 +1,28 @@
+/* { dg-additional-options "-O3" } */
+/* { dg-add-options vect_early_break } */
+/* { dg-require-effective-target vect_early_break_hw } */
+
+#include <stdint.h>
+#include "tree-vect.h"
+
+typedef signed _BitInt(24) i24;
+int8_t m0[2];
+
+int __attribute__((noipa))
+foo (int16_t in2)
+{
+ int16_t x2;
+ int n = 0;
+ for (n = 0; n < 8; n++) {
+ if (((i24)(m0[1] ? m0[1] * 2 : 1) >= (i24)(x2 - 1))) break;
+ }
+ return n;
+}
+
+int main(void)
+{
+ check_vect ();
+ if (foo (-1))
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index c1900f8eefe..42c8516ea0a 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -12436,6 +12436,13 @@ vectorizable_comparison_1 (vec_info *vinfo, tree
vectype,
&& (VECTOR_BOOLEAN_TYPE_P (vectype1) ^ VECTOR_BOOLEAN_TYPE_P (vectype2)))
return false;
+ /* We cannot compare non-mode precision _BitInt types. Unlike bool
+ or bit-precision INTEGER_TYPE the padding bit values are target
+ dependent and possibly undefined. */
+ if (TREE_CODE (TREE_TYPE (rhs1)) == BITINT_TYPE
+ && !type_has_mode_precision_p (TREE_TYPE (rhs1)))
+ return false;
+
/* Boolean values may have another representation in vectors
and therefore we prefer bit operations over comparison for
them (which also works for scalar masks). We store opcodes
--
2.51.0