public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9770] tree-optimization/101105 - fix runtime alias test optimization
@ 2021-10-13 10:09 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-10-13 10:09 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:641bea75ab2b3567dfa66370dea8b810b504d3cc
commit r9-9770-g641bea75ab2b3567dfa66370dea8b810b504d3cc
Author: Richard Biener <rguenther@suse.de>
Date: Wed Jun 23 12:43:03 2021 +0200
tree-optimization/101105 - fix runtime alias test optimization
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.
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.
Diff:
---
gcc/testsuite/gcc.dg/torture/pr101105.c | 19 +++++++++++++++++++
gcc/tree-vect-data-refs.c | 14 +++++++++++---
2 files changed, 30 insertions(+), 3 deletions(-)
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 f2e1766432b..151bffa7714 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -3424,9 +3424,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;
@@ -3478,10 +3478,18 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
dr_vec_info *dr_info_b = loop_vinfo->lookup_dr (DDR_B (ddr));
stmt_vec_info stmt_info_b = dr_info_b->stmt;
+ 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), 0)));
+
/* Skip the pair if inter-iteration dependencies are irrelevant
and intra-iteration dependencies are guaranteed to be honored. */
if (ignore_step_p
- && (vect_preserves_scalar_order_p (dr_info_a, dr_info_b)
+ && (preserves_scalar_order_p
|| vectorizable_with_step_bound_p (dr_info_a, dr_info_b,
&lower_bound)))
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-13 10:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 10:09 [gcc r9-9770] tree-optimization/101105 - fix runtime alias test optimization 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).