* [PATCH] middle-end/110232 - fix native interpret of vector <signed-boolean:1>
@ 2023-06-13 8:42 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-06-13 8:42 UTC (permalink / raw)
To: gcc-patches
The following fixes native interpretation of a buffer as boolean
vector with bit-precision elements such as AVX512 vectors. The
check whether the buffer covers the whole vector was broken for
bit-precision elements and the following instead implements it
based on the vector type size.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR middle-end/110232
* fold-const.cc (native_interpret_vector): Use TYPE_SIZE_UNIT
to check whether the buffer covers the whole vector.
* gcc.target/i386/pr110232.c: New testcase.
---
gcc/fold-const.cc | 11 ++++-------
gcc/testsuite/gcc.target/i386/pr110232.c | 12 ++++++++++++
2 files changed, 16 insertions(+), 7 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/pr110232.c
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 84b0d06b819..9ea055d4523 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -8796,16 +8796,13 @@ native_interpret_vector_part (tree type, const unsigned char *bytes,
static tree
native_interpret_vector (tree type, const unsigned char *ptr, unsigned int len)
{
- tree etype;
- unsigned int size;
- unsigned HOST_WIDE_INT count;
+ unsigned HOST_WIDE_INT size;
- etype = TREE_TYPE (type);
- size = GET_MODE_SIZE (SCALAR_TYPE_MODE (etype));
- if (!TYPE_VECTOR_SUBPARTS (type).is_constant (&count)
- || size * count > len)
+ if (!tree_to_poly_uint64 (TYPE_SIZE_UNIT (type)).is_constant (&size)
+ || size > len)
return NULL_TREE;
+ unsigned HOST_WIDE_INT count = TYPE_VECTOR_SUBPARTS (type).to_constant ();
return native_interpret_vector_part (type, ptr, len, count, 1);
}
diff --git a/gcc/testsuite/gcc.target/i386/pr110232.c b/gcc/testsuite/gcc.target/i386/pr110232.c
new file mode 100644
index 00000000000..43b74b15e00
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr110232.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=znver4 --param vect-partial-vector-usage=2 -fno-vect-cost-model -fdump-tree-vect" } */
+
+int a[4096];
+
+void foo ()
+{
+ for (int i = 1; i < 4095; ++i)
+ a[i] = 42;
+}
+
+/* { dg-final { scan-tree-dump-not "VIEW_CONVERT_EXPR" "vect" } } */
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-13 8:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 8:42 [PATCH] middle-end/110232 - fix native interpret of vector <signed-boolean:1> Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).