public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-10014] tree-optimization/105148 - fix IVOPTs recording uses
@ 2022-05-19 14:03 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-05-19 14:03 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:64b3a86d33e08072ea78f2a87c8a275bd15f07cb
commit r11-10014-g64b3a86d33e08072ea78f2a87c8a275bd15f07cb
Author: Richard Biener <rguenther@suse.de>
Date: Tue Apr 5 16:06:10 2022 +0200
tree-optimization/105148 - fix IVOPTs recording uses
The following fixes recording uses in ARRAY_REFs with non-constant
element size or low bound.
2022-04-05 Richard Biener <rguenther@suse.de>
PR tree-optimization/105148
* tree-ssa-loop-ivopts.c (idx_record_use): Walk raw operands
2 and 3 of ARRAY_REFs.
* gcc.dg/torture/pr105148.c: New testcase.
(cherry picked from commit 86242eb1bd03eba82d8e22b01b16925d43bcc539)
Diff:
---
gcc/testsuite/gcc.dg/torture/pr105148.c | 20 ++++++++++++++++++++
gcc/tree-ssa-loop-ivopts.c | 6 ++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/torture/pr105148.c b/gcc/testsuite/gcc.dg/torture/pr105148.c
new file mode 100644
index 00000000000..3338b0f3281
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr105148.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+
+extern void foo (void);
+
+static inline int
+bar (int n)
+{
+ for (int i = 0; i < n; i++)
+ {
+ foo ();
+ int y[1][i];
+ y[n][i] = 0;
+ }
+}
+
+int
+baz (void)
+{
+ return bar (5);
+}
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 4012ae3f19d..913b3ad4258 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -2125,8 +2125,10 @@ idx_record_use (tree base, tree *idx,
find_interesting_uses_op (data, *idx);
if (TREE_CODE (base) == ARRAY_REF || TREE_CODE (base) == ARRAY_RANGE_REF)
{
- find_interesting_uses_op (data, array_ref_element_size (base));
- find_interesting_uses_op (data, array_ref_low_bound (base));
+ if (TREE_OPERAND (base, 2))
+ find_interesting_uses_op (data, TREE_OPERAND (base, 2));
+ if (TREE_OPERAND (base, 3))
+ find_interesting_uses_op (data, TREE_OPERAND (base, 3));
}
return true;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-19 14:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 14:03 [gcc r11-10014] tree-optimization/105148 - fix IVOPTs recording uses 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).