------- Comment #16 from rguenther at suse dot de  2009-11-21 12:19 -------
Subject: Re:  [4.4/4.5 Regression] Vectorizer
 cannot deal with PAREN_EXPR gracefully, 50% performance regression

On Sat, 21 Nov 2009, toon at moene dot org wrote:

> ------- Comment #15 from toon at moene dot org  2009-11-21 12:11 -------
> > I don't see that the standard suggests the specific code the Frontend
> > generates.  In fact it should be valid to increment the DO variable
> > by m3 and express the exit test in terms of the DO variable as well.
> 
> The Standard doesn't prescribe the code the Frontend generates - however, to 
> be
> sure one follows the Standard, it's most easy to simply implement the steps
> given.
> 
> To illustrate this with a simple example:
> 
> DO I = M1, M2, M3
>    B(I) = A(I)
> ENDDO
> 
> would be most easily, and atraightforwardly, implemented as follows:
> 
>      IF (M3 > 0 .AND. M1 < M2) GOTO 200  ! Loop executed zero times
>      IF (M3 < 0 .AND. M1 > M2) GOTO 200  ! Ditto
>      ITEMP = (M2 - M1 + M3) / M3         ! Temporary loop count
>      I     = M1
>  100 CONTINUE
>      B(I)  = A(I)
>      ITEMP = ITEMP - 1                   ! Adjust internal loop counter
>      I     = I + M3                      ! Adjust DO loop variable
>      IF (ITEMP > 0) GOTO 100
>  200 CONTINUE
> 
> That there are two induction variables in this loop is inconsequential - one 
> of
> them should be eliminated by induction variable elimination (at least, that 
> was
> the case with g77 and the RTL loop optimization pass).

Sure, but the frontend generates

  if (M3 > 0)
     ITEMP = (M2 - M1) / M3
  else
     ITEMP = (M1 - M2) / -M3
  I = M1
100 CONTINUE
  B(I) = A(I)
  I = I + M3
  if (ITEMP == 0) GOTO 200
  ITEMP = ITEMP - 1
  GOTO 100
200 CONTINUE

The conditional setting of ITEMP is what confuses GCC.  Also I don't
see the test for zero-time executing loops (but maybe I omitted it
from my pasting in comment #12).

Richard.


-- 


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

Reply via email to