From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/114485 - neg induction with partial vectors
Date: Thu, 4 Apr 2024 10:05:45 +0200 (CEST) [thread overview]
Message-ID: <20240404080545.YlLdaDKJYNN6fW7-I9jPCDXWDt4o8fNUJ8xw1dcP-nQ@z> (raw)
We can't use vect_update_ivs_after_vectorizer for partial vectors,
the following fixes vect_can_peel_nonlinear_iv_p accordingly.
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
We could handle this case by vectorizing the live lane but that's
a different thing and might be tackled next stage1.
PR tree-optimization/114485
* tree-vect-loop-manip.cc (vect_can_peel_nonlinear_iv_p):
vect_step_op_neg isn't OK for partial vectors but only
for unknown niter.
* gcc.dg/vect/pr114485.c: New testcase.
---
gcc/testsuite/gcc.dg/vect/pr114485.c | 18 ++++++++++++++++++
gcc/tree-vect-loop-manip.cc | 14 +++++++-------
2 files changed, 25 insertions(+), 7 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/vect/pr114485.c
diff --git a/gcc/testsuite/gcc.dg/vect/pr114485.c b/gcc/testsuite/gcc.dg/vect/pr114485.c
new file mode 100644
index 00000000000..6536806e350
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr114485.c
@@ -0,0 +1,18 @@
+#include "tree-vect.h"
+
+int b, c = 8, d;
+int e[23];
+int main()
+{
+ check_vect ();
+
+ int *h = e;
+ for (int i = 1; i < b + 21; i += 2)
+ {
+ c *= -1;
+ d = h[i] ? i : 0;
+ }
+ if (c != 8)
+ abort ();
+ return 0;
+}
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index 56a6d8e4a8d..8d9b533d50f 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -2128,18 +2128,18 @@ vect_can_peel_nonlinear_iv_p (loop_vec_info loop_vinfo,
For shift, when shift mount >= precision, there would be UD.
For mult, don't known how to generate
init_expr * pow (step, niters) for variable niters.
- For neg, it should be ok, since niters of vectorized main loop
+ For neg unknown niters are ok, since niters of vectorized main loop
will always be multiple of 2.
- See also PR113163 and PR114196. */
- if ((!LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant ()
- || LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo)
- || !LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))
- && induction_type != vect_step_op_neg)
+ See also PR113163, PR114196 and PR114485. */
+ if (!LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant ()
+ || LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo)
+ || (!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
+ && induction_type != vect_step_op_neg))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
"Peeling for epilogue is not supported"
- " for nonlinear induction except neg"
+ " for this nonlinear induction"
" when iteration count is unknown or"
" when using partial vectorization.\n");
return false;
--
2.35.3
reply other threads:[~2024-04-04 8:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240404080545.YlLdaDKJYNN6fW7-I9jPCDXWDt4o8fNUJ8xw1dcP-nQ@z \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).