* [PATCH] middle-end/112740 - vector boolean CTOR expansion issue
@ 2024-01-10 14:25 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2024-01-10 14:25 UTC (permalink / raw)
To: gcc-patches
The optimization to expand uniform boolean vectors by sign-extension
works only for dense masks but it failed to check that.
Bootstrap and regtest running on x86_64-unknown-linux-gnu, I've
checked aarch64 RTL expansion for the testcase. Will push tomorrow.
Richard.
PR middle-end/112740
* expr.cc (store_constructor): Check the integer vector
mask has a single bit per element before using sign-extension
to expand an uniform vector.
* gcc.dg/pr112740.c: New testcase.
---
gcc/expr.cc | 8 +++++---
gcc/testsuite/gcc.dg/pr112740.c | 19 +++++++++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/pr112740.c
diff --git a/gcc/expr.cc b/gcc/expr.cc
index dc816bc20fa..0bf80832fe5 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -7841,10 +7841,12 @@ store_constructor (tree exp, rtx target, int cleared, poly_int64 size,
break;
}
/* Use sign-extension for uniform boolean vectors with
- integer modes. Effectively "vec_duplicate" for bitmasks. */
- if (!TREE_SIDE_EFFECTS (exp)
+ integer modes and single-bit mask entries.
+ Effectively "vec_duplicate" for bitmasks. */
+ if (elt_size == 1
+ && !TREE_SIDE_EFFECTS (exp)
&& VECTOR_BOOLEAN_TYPE_P (type)
- && SCALAR_INT_MODE_P (mode)
+ && SCALAR_INT_MODE_P (TYPE_MODE (type))
&& (elt = uniform_vector_p (exp))
&& !VECTOR_TYPE_P (TREE_TYPE (elt)))
{
diff --git a/gcc/testsuite/gcc.dg/pr112740.c b/gcc/testsuite/gcc.dg/pr112740.c
new file mode 100644
index 00000000000..8250cafd2ff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr112740.c
@@ -0,0 +1,19 @@
+/* { dg-do run { target { int128 } } } */
+/* { dg-options "" } */
+
+typedef unsigned __int128 __attribute__((__vector_size__ (16))) V;
+
+V
+foo (unsigned c, V v)
+{
+ return (V) (c <= v) == 0;
+}
+
+int
+main (void)
+{
+ V x = foo (0, (V) { });
+ if (x[0])
+ __builtin_abort ();
+ return 0;
+}
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-10 14:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-10 14:25 [PATCH] middle-end/112740 - vector boolean CTOR expansion issue 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).