[Loop Vectorize] Question on -O3

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Loop Vectorize] Question on -O3

maxs
Hi,
   When I use "-loop-vectorize" to vectorize a loop as below:
//====================================
void bar(float *A, float* B, float K, int start, int end) {
  for (int i = start; i < end; ++i)
    A[i] *= B[i] + K;
}
//====================================
  First, I use "clang -O0 -emit-llvm -S bar.c -o bar.l" to emit the .l file.
  Then I use "opt -loop-vectorize -S bar.l -o bar.v.l". Unfortunately, the vectorization don't work. But I use "opt -O3 -loop-vectorize -S bar.l -o bar.v.l" and it works.
  My question is: What the information needed by "-loop-vectorize" the "-O3" provides? Thanks.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [Loop Vectorize] Question on -O3

Duncan Sands
Hi maxs,

On 02/07/13 09:49, maxs wrote:

> Hi,
>     When I use "-loop-vectorize" to vectorize a loop as below:
> //====================================
> void bar(float *A, float* B, float K, int start, int end) {
>    for (int i = start; i < end; ++i)
>      A[i] *= B[i] + K;
> }
> //====================================
>    First, I use "*clang -O0 -emit-llvm -S bar.c -o bar.l*" to emit the .l file.
>    Then I use "*opt -loop-vectorize -S bar.l -o bar.v.l*". Unfortunately, the
> vectorization don't work. But I use "*opt -O3 -loop-vectorize -S bar.l -o
> bar.v.l*" and it works.
>    My question is: What the information needed by "*-loop-vectorize*" the
> "*-O3*" provides? Thanks.

all of the advanced LLVM optimizations assume that the IR has already been
cleaned up already by the less advanced optimizers.  Try running something
like -sroa -instcombine -simplifycfg first.

Ciao, Duncan.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [Loop Vectorize] Question on -O3

Renato Golin-2
On 2 July 2013 12:00, Duncan Sands <[hidden email]> wrote:
all of the advanced LLVM optimizations assume that the IR has already been
cleaned up already by the less advanced optimizers.  Try running something
like -sroa -instcombine -simplifycfg first.

There could be a warning on more advanced optimizations if the pre-requisites haven't run (as per individual call). And maybe a way to force the dependencies to run regardless of the On level. Not sure how this dependency system would be constructed, though.

--renato

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [Loop Vectorize] Question on -O3

Duncan Sands
Hi Renato,

On 02/07/13 13:12, Renato Golin wrote:

> On 2 July 2013 12:00, Duncan Sands <[hidden email] <mailto:[hidden email]>>
> wrote:
>
>     all of the advanced LLVM optimizations assume that the IR has already been
>     cleaned up already by the less advanced optimizers.  Try running something
>     like -sroa -instcombine -simplifycfg first.
>
>
> There could be a warning on more advanced optimizations if the pre-requisites
> haven't run (as per individual call). And maybe a way to force the dependencies
> to run regardless of the On level. Not sure how this dependency system would be
> constructed, though.

they aren't dependencies in the sense that they aren't needed for correct
functioning.  They are only needed to get decent results.  But then you get
into a minefield, since all kinds of optimizations can expose stuff that
causes other optimizers to do stuff that causes other optimizers to do stuff
that (... repeat many times) that  ends up allowing the loop vectorizer to do
more.  Anyway, since "opt" is a developer tool I think it is reasonable to
require people to understand stuff rather than trying to have it all happen
automagically (such an automagic system wouldn't be useful for clang and other
frontends anyway, so in a sense would just represent pointless complexity).

Ciao, Duncan.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [Loop Vectorize] Question on -O3

Renato Golin-2
On 2 July 2013 12:26, Duncan Sands <[hidden email]> wrote:
Anyway, since "opt" is a developer tool I think it is reasonable to
require people to understand stuff rather than trying to have it all happen
automagically (such an automagic system wouldn't be useful for clang and other
frontends anyway, so in a sense would just represent pointless complexity).

Yes. Opt should be bare, but Clang/llc could have some facility in that area.

I agree they're not dependencies, but they might give the wrong impression when the "nice-to-have" passes didn't run...

cheers,
--renato

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev