[LLVMdev] loop vectorizer misses opportunity, exploit

Hal Finkel hfinkel at anl.gov
Thu Oct 31 09:42:04 PDT 2013


----- Original Message -----
> 
> On 31 October 2013 08:01, Frank Winter < fwinter at jlab.org > wrote:
> 
> 
> 
> 
> 
> 
> With current trunk I tried the following on the above example:
> 
> clang++ -emit-llvm -S loop_minimal.cc -std=c++11
> opt -O3 -vectorize-slp -S loop_minimal.ll
> opt -O3 -loop-vectorize -S loop_minimal.ll
> opt -O3 -bb-vectorize -S loop_minimal.ll
> 
> All optimization passes miss the opportunity. It seems the SCEV AA
> pass doesn't understand modulo arithmetic.
> 
> 
> Hi Frank,
> 
> 
> IIRC, opt -O3 will already pass all three, so you don't have to add
> it to the command line.

-O3 will not automatically add the -bb-vectorize in clang or in opt. From Clang, SLP and loop vectorization are enabled from -O3. From opt, I don't believe that this is true (although we should probably fix that).

> 
> 
> 
> 
> 
> 
> 
> How can the SCEV AA pass be extended to handle this type of
> arithmetic?

To be clear, the loop vectorizer does not use the SCEV AA analysis to do dependence checking. It uses SCEV in its own internal memory dependence checking class.

 -Hal

> 
> 
> I'm not an SCEV expert, so it might be possible that it does
> understand, but the loop vectorizer is not understanding the
> evolution info, or whatever.
> 
> 
> What I recommend is to step through the loop vectorizer
> (canVectorize) and see what the SCEV returns to the vectorizer. If
> the info is there, but not accounted for, it's a vectorizer bug. If
> the SCEV gets lost, than you need to add it into the SCEV logic.
> 
> 
> cheers,
> --renato

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-dev mailing list