public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jiu Fu Guo <guojiufu@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-4082] use local range for one more pattern in match.pd Date: Mon, 18 Sep 2023 02:19:05 +0000 (GMT) [thread overview] Message-ID: <20230918021905.AFE063858D32@sourceware.org> (raw) https://gcc.gnu.org/g:55b22a6f630e76a0be913ced8bf1b017eaffd89b commit r14-4082-g55b22a6f630e76a0be913ced8bf1b017eaffd89b Author: Jiufu Guo <guojiufu@linux.ibm.com> Date: Wed Sep 13 16:12:05 2023 +0800 use local range for one more pattern in match.pd For "get_global_range_query" SSA_NAME_RANGE_INFO can be queried. For "get_range_query", it could get more context-aware range info. And look at the implementation of "get_range_query", it returns global range if no local fun info. ATTRIBUTE_RETURNS_NONNULL inline range_query * get_range_query (const struct function *fun) { return (fun && fun->x_range_query) ? fun->x_range_query : &global_ranges; } So, using "get_range_query" would cover more case. For example, the test case of "pr111303.c". PR middle-end/111303 gcc/ChangeLog: * match.pd ((t * 2) / 2): Update pattern. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr111303.c: New test. Diff: --- gcc/match.pd | 4 ++-- gcc/testsuite/gcc.dg/tree-ssa/pr111303.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 39c9c81966a..87edf0e75c3 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -931,8 +931,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) bool overflowed = true; value_range vr0, vr1; if (INTEGRAL_TYPE_P (type) - && get_global_range_query ()->range_of_expr (vr0, @0) - && get_global_range_query ()->range_of_expr (vr1, @1) + && get_range_query (cfun)->range_of_expr (vr0, @0) + && get_range_query (cfun)->range_of_expr (vr1, @1) && !vr0.varying_p () && !vr0.undefined_p () && !vr1.varying_p () && !vr1.undefined_p ()) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr111303.c b/gcc/testsuite/gcc.dg/tree-ssa/pr111303.c new file mode 100644 index 00000000000..b703fe4546d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr111303.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +typedef unsigned int INT; + +INT +foo (INT x, INT y) +{ + if (x > 100 || y > 100) + return x; + return (x * y) / y; +} + +/* { dg-final { scan-tree-dump-times "return x_..D." 1 "optimized"} } */ +/* { dg-final { scan-tree-dump-times " / " 0 "optimized"} } */
reply other threads:[~2023-09-18 2:19 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=20230918021905.AFE063858D32@sourceware.org \ --to=guojiufu@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).