public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1000] Don't simplify (A & C) != 0 ? D : 0 for pointer types. Date: Sun, 23 May 2021 08:08:41 +0000 (GMT) [thread overview] Message-ID: <20210523080841.7AFC93857C52@sourceware.org> (raw) https://gcc.gnu.org/g:99b76adb94d9363d0ca31a7d34ce850e2ca9ffc5 commit r12-1000-g99b76adb94d9363d0ca31a7d34ce850e2ca9ffc5 Author: Andrew Pinski <apinski@marvell.com> Date: Sun May 16 10:40:16 2021 -0700 Don't simplify (A & C) != 0 ? D : 0 for pointer types. While rewriting part of PHI-OPT to use match-and-simplify, I ran into a bug where this pattern in match.pd would hit and would produce invalid gimple; a shift of a pointer type. This just disables this simplification for pointer types similarly to what is already done in PHI-OPT for the generic A ? D : 0 case. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Thanks, Andrew Pinski 2021-5-23 Andrew Pinski <apinski@marvell.com> gcc/ * match.pd ((A & C) != 0 ? D : 0): Limit to non pointer types. gcc/testsuite/ * gcc.dg/gimplefe-45.c: New test. Diff: --- gcc/match.pd | 2 +- gcc/testsuite/gcc.dg/gimplefe-45.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc/match.pd b/gcc/match.pd index e01bb7a4080..1fc6b7b1557 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -4840,7 +4840,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cond (ne (bit_and @0 integer_pow2p@1) integer_zerop) INTEGER_CST@2 integer_zerop) - (if (integer_pow2p (@2)) + (if (!POINTER_TYPE_P (type) && integer_pow2p (@2)) (with { int shift = (wi::exact_log2 (wi::to_wide (@2)) - wi::exact_log2 (wi::to_wide (@1))); diff --git a/gcc/testsuite/gcc.dg/gimplefe-45.c b/gcc/testsuite/gcc.dg/gimplefe-45.c new file mode 100644 index 00000000000..b1d3cbb0205 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-45.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgimple" } */ + +/* This used to ICE when simplifying (A & C) != 0 ? D : 0 + for pointer types. */ + +int *__GIMPLE () +p (int n) +{ + int *_2; + int *_t; + int *_t1; + _t = (int*)8; + _t1 = 0; + n = n & 2; + _2 = n != 0 ? _t : _t1; + return _2; +} +
reply other threads:[~2021-05-23 8:08 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=20210523080841.7AFC93857C52@sourceware.org \ --to=pinskia@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).