public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "guojiufu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/108757] We do not simplify (a - (N*M)) / N + M -> a / N
Date: Fri, 12 May 2023 01:52:32 +0000	[thread overview]
Message-ID: <bug-108757-4-YaAwVOG2nW@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108757-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108757

--- Comment #22 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #21)
> (In reply to Jiu Fu Guo from comment #20)
> > Interesting thing:
> > the VR is always VR_VARYING, even for the below simple case:
> > 
> > typedef unsigned long INT;
> > INT __attribute__ ((noinline)) foo (INT x)
> > {
> >   if (x < 4)
> >     return 0;
> >   INT a = x + 18446744073709551612ULL;
> >   INT b = a >> 2;
> >   return b + 1;
> > }
> 
> Yes that is because x does not have a "global" range.

I also tried "get_range_query (cfun)->range_of_expr (vr0, @0)", 
> 
> You could try the following testcase:
> ```
> typedef unsigned long INT;
> INT __attribute__ ((noinline)) foo (INT x)
> {
>   if (x < 4)
>     __builtin_unreachable();
>   INT a = x + 18446744073709551612ULL;
>   INT b = a >> 2;
>   return b + 1;
> }
> ```
> 
> Which gets a (global) range for x_1(D) during forwprop3:
>   # RANGE [irange] INT [4, +INF]
>   INTD.2750 x_1(D) = xD.2751;

(In reply to Andrew Pinski from comment #21)
> (In reply to Jiu Fu Guo from comment #20)
> > Interesting thing:
> > the VR is always VR_VARYING, even for the below simple case:
> > 
> > typedef unsigned long INT;
> > INT __attribute__ ((noinline)) foo (INT x)
> > {
> >   if (x < 4)
> >     return 0;
> >   INT a = x + 18446744073709551612ULL;
> >   INT b = a >> 2;
> >   return b + 1;
> > }
> 
> Yes that is because x does not have a "global" range.
> 
> You could try the following testcase:
> ```
> typedef unsigned long INT;
> INT __attribute__ ((noinline)) foo (INT x)
> {
>   if (x < 4)
>     __builtin_unreachable();
>   INT a = x + 18446744073709551612ULL;
>   INT b = a >> 2;
>   return b + 1;
> }
> ```
> 
> Which gets a (global) range for x_1(D) during forwprop3:
>   # RANGE [irange] INT [4, +INF]
>   INTD.2750 x_1(D) = xD.2751;

Thanks so much!
"get_range_query (cfun)->range_of_expr (vr0, @0)" works for both the case!

  parent reply	other threads:[~2023-05-12  1:52 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-10 22:26 [Bug tree-optimization/108757] New: " bergner at gcc dot gnu.org
2023-02-10 22:28 ` [Bug tree-optimization/108757] " bergner at gcc dot gnu.org
2023-02-10 22:33 ` pinskia at gcc dot gnu.org
2023-02-10 22:40 ` pinskia at gcc dot gnu.org
2023-02-11 13:14 ` anlauf at gcc dot gnu.org
2023-02-11 16:38 ` segher at gcc dot gnu.org
2023-02-11 17:32 ` bergner at gcc dot gnu.org
2023-02-11 17:55 ` segher at gcc dot gnu.org
2023-02-11 18:05 ` bergner at gcc dot gnu.org
2023-02-11 18:15 ` segher at gcc dot gnu.org
2023-02-11 19:45 ` chip.kerchner at ibm dot com
2023-02-11 21:55 ` chip.kerchner at ibm dot com
2023-02-11 22:03 ` chip.kerchner at ibm dot com
2023-02-13 20:13 ` chip.kerchner at ibm dot com
2023-02-13 20:20 ` pinskia at gcc dot gnu.org
2023-02-13 20:27 ` [Bug rtl-optimization/108757] " pinskia at gcc dot gnu.org
2023-02-13 20:36 ` chip.kerchner at ibm dot com
2023-02-13 20:37 ` chip.kerchner at ibm dot com
2023-02-13 20:58 ` [Bug tree-optimization/108757] " pinskia at gcc dot gnu.org
2023-02-13 20:59 ` pinskia at gcc dot gnu.org
2023-02-13 21:01 ` pinskia at gcc dot gnu.org
2023-05-11 13:15 ` guojiufu at gcc dot gnu.org
2023-05-11 17:32 ` pinskia at gcc dot gnu.org
2023-05-12  1:52 ` guojiufu at gcc dot gnu.org [this message]
2023-05-12  6:25 ` guojiufu at gcc dot gnu.org
2023-05-12  9:35 ` guojiufu at gcc dot gnu.org
2023-09-04  2:46 ` cvs-commit at gcc dot gnu.org
2023-09-04  3:26 ` guojiufu at gcc dot gnu.org

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=bug-108757-4-YaAwVOG2nW@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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: link
Be 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).