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 r15-793] tree-optimization/115197 - fix ICE w/ constant in LC PHI and loop distribution Date: Thu, 23 May 2024 13:45:37 +0000 (GMT) [thread overview] Message-ID: <20240523134537.328973865488@sourceware.org> (raw) https://gcc.gnu.org/g:2b2476d4d18c92b8aba3567ebccd2100c2f7c258 commit r15-793-g2b2476d4d18c92b8aba3567ebccd2100c2f7c258 Author: Richard Biener <rguenther@suse.de> Date: Thu May 23 14:36:39 2024 +0200 tree-optimization/115197 - fix ICE w/ constant in LC PHI and loop distribution Forgot a check for an SSA name before trying to replace a PHI arg with its current definition. PR tree-optimization/115197 * tree-loop-distribution.cc (copy_loop_before): Constant PHI args remain the same. * gcc.dg/pr115197.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/pr115197.c | 14 ++++++++++++++ gcc/tree-loop-distribution.cc | 7 +++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/pr115197.c b/gcc/testsuite/gcc.dg/pr115197.c new file mode 100644 index 00000000000..00d674b3bd9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr115197.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-scev-cprop -ftree-pre -ftree-loop-distribute-patterns" } */ + +int a, b[2], c, d, e, f[2]; +int main() { + while (a) + if (d) { + if (e) + return 0; + for (; c; c++) + f[c] = 0 < (b[c] = ~(f[c + 1] < a)); + } + return 0; +} diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc index 668dc420449..4d1ed234fcb 100644 --- a/gcc/tree-loop-distribution.cc +++ b/gcc/tree-loop-distribution.cc @@ -977,8 +977,11 @@ copy_loop_before (class loop *loop, bool redirect_lc_phi_defs) if (virtual_operand_p (gimple_phi_result (phi))) continue; use_operand_p use_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, exit); - tree new_def = get_current_def (USE_FROM_PTR (use_p)); - SET_USE (use_p, new_def); + if (TREE_CODE (USE_FROM_PTR (use_p)) == SSA_NAME) + { + tree new_def = get_current_def (USE_FROM_PTR (use_p)); + SET_USE (use_p, new_def); + } } }
reply other threads:[~2024-05-23 13:45 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=20240523134537.328973865488@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).