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 r13-5136] tree-optimization/108387 - ICE with VN handling of x << C as x * (1<<C) Date: Fri, 13 Jan 2023 09:48:12 +0000 (GMT) [thread overview] Message-ID: <20230113094812.6AC8B3854811@sourceware.org> (raw) https://gcc.gnu.org/g:adbee4a197c7b735a3dd58cfac8933f70069f71d commit r13-5136-gadbee4a197c7b735a3dd58cfac8933f70069f71d Author: Richard Biener <rguenther@suse.de> Date: Fri Jan 13 08:37:24 2023 +0100 tree-optimization/108387 - ICE with VN handling of x << C as x * (1<<C) The following fixes unexpected simplification of x << C as x * (1<<C) to a constant. PR tree-optimization/108387 * tree-ssa-sccvn.cc (visit_nary_op): Check for SSA_NAME value before inserting expression into the tables. * gcc.dg/pr108387.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/pr108387.c | 13 +++++++++++++ gcc/tree-ssa-sccvn.cc | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/pr108387.c b/gcc/testsuite/gcc.dg/pr108387.c new file mode 100644 index 00000000000..114186b6c5d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr108387.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-ccp" } */ + +void bar2 (unsigned char, unsigned char); + +void +foo1 (char c) +{ + unsigned char t = c; + t *= 2; + unsigned char t1 = t << 7; + bar2 (t, t1); +} diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index a01022b0d12..0dba3f39aa0 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -5405,7 +5405,8 @@ visit_nary_op (tree lhs, gassign *stmt) if (result) { bool changed = set_ssa_val_to (lhs, result); - vn_nary_op_insert_stmt (stmt, result); + if (TREE_CODE (result) == SSA_NAME) + vn_nary_op_insert_stmt (stmt, result); return changed; } }
reply other threads:[~2023-01-13 9:48 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=20230113094812.6AC8B3854811@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).