public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/42117] VRP should do if-conversion
       [not found] <bug-42117-4@http.gcc.gnu.org/bugzilla/>
@ 2021-06-06  6:24 ` pinskia at gcc dot gnu.org
  2021-07-06  8:01 ` pinskia at gcc dot gnu.org
  2023-06-10  2:12 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-06  6:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine, I will take a look.

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

* [Bug tree-optimization/42117] VRP should do if-conversion
       [not found] <bug-42117-4@http.gcc.gnu.org/bugzilla/>
  2021-06-06  6:24 ` [Bug tree-optimization/42117] VRP should do if-conversion pinskia at gcc dot gnu.org
@ 2021-07-06  8:01 ` pinskia at gcc dot gnu.org
  2023-06-10  2:12 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-06  8:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|42195                       |
             Status|ASSIGNED                    |NEW
           Assignee|pinskia at gcc dot gnu.org         |unassigned at gcc dot gnu.org

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I am not going to fix this.
But right now we get:
  _8 = x_5(D) | y_6(D);
  _4 = (unsigned int) _8;
  if (_4 <= 1)
    goto <bb 3>; [57.43%]
  else
    goto <bb 5>; [42.57%]

  <bb 3> [local count: 616649929]:
  if (x_5(D) != 0)
    goto <bb 4>; [50.00%]
  else
    goto <bb 5>; [50.00%]

  <bb 4> [local count: 126413234]:
  _9 = y_6(D) != 0;
  _1 = (int) _9;

  <bb 5> [local count: 1073741824]:
  # _3 = PHI <x_5(D)(3), _1(4), -1(2)>

Part of the problem is realizing y_6 is [0,1] range when looking at _9/_1.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42195
[Bug 42195] missed xnor optimization.

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

* [Bug tree-optimization/42117] VRP should do if-conversion
       [not found] <bug-42117-4@http.gcc.gnu.org/bugzilla/>
  2021-06-06  6:24 ` [Bug tree-optimization/42117] VRP should do if-conversion pinskia at gcc dot gnu.org
  2021-07-06  8:01 ` pinskia at gcc dot gnu.org
@ 2023-06-10  2:12 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-10  2:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So I think VRP is almost there on the trunk, it just needs to know if you have
a range of a and that a is defined by b|c, then b and c ranges can be just the
same as a.
That is:
    _10 = x_5(D) | y_6(D);
    _11 = (unsigned int) _10;
    if (_11 <= 1)
      goto <bb 3>; [57.43%]
    else
      goto <bb 4>; [42.57%]

2->3  (T) _10 :         [irange] int [0, 1] NONZERO 0x1
2->3  (T) _11 :         [irange] unsigned int [0, 1] NONZERO 0x1
2->4  (F) _10 :         [irange] int [-INF, -1][2, +INF]
2->4  (F) _11 :         [irange] unsigned int [2, +INF]

We should have done:
2->3 (T) x_5(D) :       [irange] int [0, 1] NONZERO 0x1
2->3 (T) y_6(D) :       [irange] int [0, 1] NONZERO 0x1
...

This is only true for bit_ior.

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

* [Bug tree-optimization/42117] VRP should do if-conversion
  2009-11-20 12:49 [Bug tree-optimization/42117] New: VRP fails to get rid of compares krebbel at gcc dot gnu dot org
@ 2009-11-20 13:12 ` rguenth at gcc dot gnu dot org
  0 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-20 13:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2009-11-20 13:12 -------
Confirmed.  We do see

x_2: [0, 1]  EQUIVALENCES: { x_3(D) } (1 elements)
y_11: [0, 1]  EQUIVALENCES: { y_5(D) } (1 elements)

but have no code that actually makes use of this information in

<bb 4>:
  if (x_3(D) != 0)
    goto <bb 5>;
  else
    goto <bb 6>;

<bb 5>:
  if (y_5(D) != 0)
    goto <bb 7>;
  else
    goto <bb 6>;

<bb 6>:

<bb 7>:
  # D.2047_1 = PHI <0(6), -1(3), -1(2), 1(5)>
  return D.2047_1;

which we want to if-convert to

<bb 4>:
  tmp = x_3 & y_5;

<bb 7>:
  # D.2047_1 = PHI <tmp(4), -1(3), -1(2)>

but there is no code in VRP that does if-conversion.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-11-20 13:12:34
               date|                            |
            Summary|VRP fails to get rid of     |VRP should do if-conversion
                   |compares                    |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42117


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

end of thread, other threads:[~2023-06-10  2:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-42117-4@http.gcc.gnu.org/bugzilla/>
2021-06-06  6:24 ` [Bug tree-optimization/42117] VRP should do if-conversion pinskia at gcc dot gnu.org
2021-07-06  8:01 ` pinskia at gcc dot gnu.org
2023-06-10  2:12 ` pinskia at gcc dot gnu.org
2009-11-20 12:49 [Bug tree-optimization/42117] New: VRP fails to get rid of compares krebbel at gcc dot gnu dot org
2009-11-20 13:12 ` [Bug tree-optimization/42117] VRP should do if-conversion rguenth at gcc dot gnu dot 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).