public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102794] New: [12 Regression] missing vrp in evrp dealing with casts and ands
@ 2021-10-16  4:49 pinskia at gcc dot gnu.org
  2021-10-16  4:50 ` [Bug tree-optimization/102794] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-16  4:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102794
           Summary: [12 Regression] missing vrp in evrp dealing with casts
                    and ands
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
void foo(void);
int main() {
  int b = 0;
  int a = -100;
  for (; a; ++a) {
    unsigned short d = a;
    if (!(b | d) && d)
      foo();
  }
  return 0;
}

--- CUT ----
This used to be optimized during evrp in 11.1.0/11.2.0 but trunk evrp does not.
This is reduced from PR 102703 but is related issue though different.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/102794] [12 Regression] missing vrp in evrp dealing with casts and ands
  2021-10-16  4:49 [Bug tree-optimization/102794] New: [12 Regression] missing vrp in evrp dealing with casts and ands pinskia at gcc dot gnu.org
@ 2021-10-16  4:50 ` pinskia at gcc dot gnu.org
  2021-10-16  5:01 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-16  4:50 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/102794] [12 Regression] missing vrp in evrp dealing with casts and ands
  2021-10-16  4:49 [Bug tree-optimization/102794] New: [12 Regression] missing vrp in evrp dealing with casts and ands pinskia at gcc dot gnu.org
  2021-10-16  4:50 ` [Bug tree-optimization/102794] " pinskia at gcc dot gnu.org
@ 2021-10-16  5:01 ` pinskia at gcc dot gnu.org
  2021-10-16  7:07 ` aldyh at redhat dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-16  5:01 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aldyh at gcc dot gnu.org

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Jump threading really messes up the loop here ...
about to thread: path: 4 -> 6, 6 -> 7, 7 -> 3, 
just threaded: path: 4 -> 9, 6 -> 7, 7 -> 3, 

I don't know what else to say.  Maybe move ethread after evpr?

Note with -fno-thread-jumps, evpr is able to figure out the induction variable
goes from [-100, -1] .  It does look like jump threading is full on messing up
how induction variable detection works; we get two a = a +1; statement after
the jump threading improvements.
Maybe there is another bug about that case already.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/102794] [12 Regression] missing vrp in evrp dealing with casts and ands
  2021-10-16  4:49 [Bug tree-optimization/102794] New: [12 Regression] missing vrp in evrp dealing with casts and ands pinskia at gcc dot gnu.org
  2021-10-16  4:50 ` [Bug tree-optimization/102794] " pinskia at gcc dot gnu.org
  2021-10-16  5:01 ` pinskia at gcc dot gnu.org
@ 2021-10-16  7:07 ` aldyh at redhat dot com
  2021-10-16  7:35 ` pinskia at gcc dot gnu.org
  2021-10-22 21:39 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: aldyh at redhat dot com @ 2021-10-16  7:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Aldy Hernandez <aldyh at redhat dot com> ---
I haven't looked at this, but there's a pending patch with more
restrictions for loop threading in the presence of loops.  Does this help?

https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581637.html

We really shouldn't be destroying loop info.


On Sat, Oct 16, 2021, 07:01 pinskia at gcc dot gnu.org <
gcc-bugzilla@gcc.gnu.org> wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102794
>
> Andrew Pinski <pinskia at gcc dot gnu.org> changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>                  CC|                            |aldyh at gcc dot gnu.org
>
> --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> Jump threading really messes up the loop here ...
> about to thread: path: 4 -> 6, 6 -> 7, 7 -> 3,
> just threaded: path: 4 -> 9, 6 -> 7, 7 -> 3,
>
> I don't know what else to say.  Maybe move ethread after evpr?
>
> Note with -fno-thread-jumps, evpr is able to figure out the induction
> variable
> goes from [-100, -1] .  It does look like jump threading is full on
> messing up
> how induction variable detection works; we get two a = a +1; statement
> after
> the jump threading improvements.
> Maybe there is another bug about that case already.
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/102794] [12 Regression] missing vrp in evrp dealing with casts and ands
  2021-10-16  4:49 [Bug tree-optimization/102794] New: [12 Regression] missing vrp in evrp dealing with casts and ands pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-10-16  7:07 ` aldyh at redhat dot com
@ 2021-10-16  7:35 ` pinskia at gcc dot gnu.org
  2021-10-22 21:39 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-16  7:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Aldy Hernandez from comment #2)
> I haven't looked at this, but there's a pending patch with more
> restrictions for loop threading in the presence of loops.  Does this help?
> 
> https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581637.html
> 
> We really shouldn't be destroying loop info.

Yes I think it does, though I have not tried it.
There was a jump threading here:
  <bb 4> :
  if (d_10 != 0)
    goto <bb 5>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 5> :
  foo ();

  <bb 6> :
  a_12 = a_3 + 1;

  <bb 7> : ;;; loop header
  # a_3 = PHI <-100(2), a_12(6)>
  if (a_3 != 0)
    goto <bb 3>; [INV]
  else
    goto <bb 8>; [INV]

where d_10 is defined as:
  d_10 = (short unsigned int) a_3;


So yes blocking jumping through the loop header would help.
It is very similar to your f3 in ssa-thread-invalid.c testcase.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/102794] [12 Regression] missing vrp in evrp dealing with casts and ands
  2021-10-16  4:49 [Bug tree-optimization/102794] New: [12 Regression] missing vrp in evrp dealing with casts and ands pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-10-16  7:35 ` pinskia at gcc dot gnu.org
@ 2021-10-22 21:39 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-22 21:39 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed most likely by r12-4526.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-10-22 21:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-16  4:49 [Bug tree-optimization/102794] New: [12 Regression] missing vrp in evrp dealing with casts and ands pinskia at gcc dot gnu.org
2021-10-16  4:50 ` [Bug tree-optimization/102794] " pinskia at gcc dot gnu.org
2021-10-16  5:01 ` pinskia at gcc dot gnu.org
2021-10-16  7:07 ` aldyh at redhat dot com
2021-10-16  7:35 ` pinskia at gcc dot gnu.org
2021-10-22 21:39 ` pinskia at gcc dot gnu.org

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).