public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-10014] tree-optimization/105148 - fix IVOPTs recording uses Date: Thu, 19 May 2022 14:03:04 +0000 (GMT) [thread overview] Message-ID: <20220519140304.438BB383E822@sourceware.org> (raw) 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; }
reply other threads:[~2022-05-19 14:03 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=20220519140304.438BB383E822@sourceware.org \ --to=rguenth@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).