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

Andrew Macleod <amacleod at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amacleod at redhat dot com

--- Comment #2 from Andrew Macleod <amacleod at redhat dot com> ---
f2 and f4 are "similar" when I look at whats going on with these.

The interesting bits are  bb3 and bb4

=========== BB 3 ============
i_9(D)  int [2, +INF]
j_10(D) int [3, +INF]
Relational : (x_12 > i_9(D))
    <bb 3> :
    x_12 = i_9(D) + 1;

x_12 : int [3, +INF]


=========== BB 4 ============
Imports: i_9(D)  j_10(D)
Exports: _4  _5  _6  i_9(D)  j_10(D)
         _4 : i_9(D)(I)
         _5 : j_10(D)(I)
         _6 : _4  _5  i_9(D)(I)  j_10(D)(I)
i_9(D)  int VARYING
j_10(D) int VARYING
    <bb 4> :
    # x_8 = PHI <x_11(D)(2), x_12(3)>
    _4 = i_9(D) == 2;
    _5 = j_10(D) == 3;
    _6 = _4 & _5;
    if (_6 != 0)
      goto <bb 5>; [INV]
    else
      goto <bb 7>; [INV]

x_8 : int [3, +INF]
4->5  (T) _4 :  _Bool [1, 1]
4->5  (T) _5 :  _Bool [1, 1]
4->5  (T) _6 :  _Bool [1, 1]
4->5  (T) i_9(D) :      int [2, 2]
4->5  (T) j_10(D) :     int [3, 3]
4->7  (F) _6 :  _Bool [0, 0]

we have the ability to recompute stmts on edges when the dependencies change.
This currently applies only to range-ops enabled stmts.  An extension to PHIS
and other non-range-ops is in the works.


The gist being x_8 is directly dependant on x_11 and x_12.  x_11 is undefined,
so it boils down to a dependency on x_12.

x_12 in turn is dependant on i_9 which is a modified export from this block. 
So when recomputation is extended to PHIS, we should be able to see that i_9
has changed on this edge, and reevaluate x_12 for that edge,
   x_12 = i_9 + 1 -->  [2,2] + 1 == [3,3] 
and feeding that into a PHI recalculation for the edge producing
 x_8 = PHI <x_11(D), [3,3]>
and then we'd resolve x_8 = [3,3] on the true edge, and the desired fold should
happen. 

The other issue is that when we do recalculations, we currently only go back
one degree of dependency for the sake of compilation speed...  x_8's direct
dependencies are that one degree..  I have not done experiments on more than
one degree, but it may make sense to look back one degree for phi arguemnts as
well,  which would then get cases like this. 

It may also make sense instead to adjust the phi optimization pass to utilize
ranger to do a more in-depth analysis of argument ranges and their dependencies
and get it there. 

I'll update this once I have enabled recomputation for phis, and have something
more concrete.

Reply via email to