Bug 31756 - Doesn't optimize the following (obvious) sequence
Summary: Doesn't optimize the following (obvious) sequence
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2007-04-29 14:56 UTC by Toon Moene
Modified: 2009-04-22 21:26 UTC (History)
3 users (show)

See Also:
Host: x64_86-unknown-gnu-linux
Target: idem
Build: idem
Known to work:
Known to fail:
Last reconfirmed: 2009-04-22 21:26:54


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Toon Moene 2007-04-29 14:56:06 UTC
Given the following Fortran source:

      SUBROUTINE SUB(A, B, N, M)
      DIMENSION A(N, M), B(N, M)
      DO I = 1, N
         DO J = 1, M
            A(I, J) = B(I, J)
         ENDDO
      ENDDO
      END

It should be vectorized using the following compile time options:

-O2 -ftree-vectorize -ftree-vectorizer-verbose=2 -ftree-loop-linear 

Unfortunately, it doesn't.
Comment 1 Daniel Berlin 2007-04-29 16:05:58 UTC
PRE optimized the "offset" and "stride" variables.
SCEV doesn't know how to create an offset or step out of these optimized operations.  We used to at some point, but I believe these are "peeled_chrec's" that we removed support for before merge.

I think it's time we add back support for these chrec's.  I can't block PRE from optimizing these variables easily.  
Comment 2 Sebastian Pop 2007-04-29 16:21:36 UTC
Subject: Re:  Doesn't optimize the following (obvious) sequence

> PRE optimized the "offset" and "stride" variables.
> SCEV doesn't know how to create an offset or step out of these optimized
> operations.

I remember another bug report like this one, and the solution was to tweak
PRE not to peel linear sequences.

> We used to at some point, but I believe these are "peeled_chrec's"
> that we removed support for before merge.
>

Yes, I had another solution for transforming back the simple peeled chrecs
to linear ones.

> I think it's time we add back support for these chrec's.  I can't block PRE
> from optimizing these variables easily.
>

agreed, I'll send a patch for this.

Sebastian
Comment 3 Daniel Berlin 2007-04-29 20:31:05 UTC
Subject: Re:  Doesn't optimize the following (obvious) sequence

On 29 Apr 2007 15:21:40 -0000, spop at gcc dot gnu dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
>
> ------- Comment #2 from spop at gcc dot gnu dot org  2007-04-29 16:21 -------
> Subject: Re:  Doesn't optimize the following (obvious) sequence
>
> > PRE optimized the "offset" and "stride" variables.
> > SCEV doesn't know how to create an offset or step out of these optimized
> > operations.
>
> I remember another bug report like this one, and the solution was to tweak
> PRE not to peel linear sequences.

Yes, i changed PRE to not peel sequences there, but this doesn't end
up looking like an easy induction variable (IE PHI with one edge
outside the loop, one edge inside the loop)
Comment 4 Andrew Pinski 2007-05-28 07:58:01 UTC
I think the problem now is related to data-ref and I think this might get fixed after I fix PR 32075.
Comment 5 Andrew Pinski 2007-05-29 23:22:29 UTC
I am wrong since this is a loop linear issue:
Won't transform loop. Optimal transform is the identity transform