From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Cc: richard.sandiford@arm.com
Subject: [PATCH] tree-optimization/101105 - fix runtime alias test optimization
Date: Wed, 23 Jun 2021 12:46:11 +0200 (CEST) [thread overview]
Message-ID: <n3p6oso-2468-608-3531-87nq684oo4n7@fhfr.qr> (raw)
We were ignoring DR_STEP for VF == 1 which is OK only in case
the scalar order is preserved or both DR steps are the same.
Bootstrapped and tested on x86_64-unknown-linux-gnu, OK?
Thanks,
Richard.
2021-06-23 Richard Biener <rguenther@suse.de>
PR tree-optimization/101105
* tree-vect-data-refs.c (vect_prune_runtime_alias_test_list):
Only ignore steps when they are equal or scalar order is preserved.
* gcc.dg/torture/pr101105.c: New testcase.
---
gcc/testsuite/gcc.dg/torture/pr101105.c | 19 +++++++++++++++++++
gcc/tree-vect-data-refs.c | 9 +++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr101105.c
diff --git a/gcc/testsuite/gcc.dg/torture/pr101105.c b/gcc/testsuite/gcc.dg/torture/pr101105.c
new file mode 100644
index 00000000000..9222351683d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101105.c
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+
+short a;
+int b[5][4] = {2, 2};
+int d;
+short e(int f) { return f == 0 || a && f == 1 ? 0 : a; }
+int main() {
+ int g, h;
+ g = 3;
+ for (; g >= 0; g--) {
+ h = 3;
+ for (; h >= 0; h--)
+ b[g][h] = b[0][1] && e(1);
+ }
+ d = b[0][1];
+ if (d != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index be067c8923b..579149dfd61 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -3479,9 +3479,9 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
/* Step values are irrelevant for aliasing if the number of vector
iterations is equal to the number of scalar iterations (which can
happen for fully-SLP loops). */
- bool ignore_step_p = known_eq (LOOP_VINFO_VECT_FACTOR (loop_vinfo), 1U);
+ bool vf_one_p = known_eq (LOOP_VINFO_VECT_FACTOR (loop_vinfo), 1U);
- if (!ignore_step_p)
+ if (!vf_one_p)
{
/* Convert the checks for nonzero steps into bound tests. */
tree value;
@@ -3534,6 +3534,11 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
bool preserves_scalar_order_p
= vect_preserves_scalar_order_p (dr_info_a, dr_info_b);
+ bool ignore_step_p
+ = (vf_one_p
+ && (preserves_scalar_order_p
+ || operand_equal_p (DR_STEP (dr_info_a->dr),
+ DR_STEP (dr_info_b->dr))));
/* Skip the pair if inter-iteration dependencies are irrelevant
and intra-iteration dependencies are guaranteed to be honored. */
--
2.26.2
next reply other threads:[~2021-06-23 10:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 10:46 Richard Biener [this message]
2021-06-23 23:56 ` Jeff Law
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=n3p6oso-2468-608-3531-87nq684oo4n7@fhfr.qr \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.sandiford@arm.com \
/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).