[LLVMdev] Failure to optimize vector select

Nadav Rotem nrotem at apple.com
Tue Aug 20 15:36:35 PDT 2013


Hi Matt, 

We are really close. :)  Now, all you have to do is teach the SLP-vectorizer to start looking at “trees” that start with this pattern:

"
  %ra = insertelement <4 x float> undef, float %s0, i32 0
  %rb = insertelement <4 x float> %ra, float %s1, i32 1
  %rc = insertelement <4 x float> %rb, float %s2, i32 2
  %rd = insertelement <4 x float> %rc, float %s3, i32 3
  ret <4 x float> %rd
"

It’s really easy to do. Look at the code in runOnFunction in SLPVectorizer.cpp ;  Just put %s0, %s1, %s2 and %s3 in a list and call tryToVectorize(…). 

Thanks,
Nadav

On Aug 20, 2013, at 3:29 PM, Matt Arsenault <arsenm2 at gmail.com> wrote:

> 
> On Aug 20, 2013, at 14:49 , Nadav Rotem <nrotem at apple.com> wrote:
> 
>> Hi Matt, 
>> 
>> This code maintains a vector of float4 and it inserts and extracts values from this vector. The ’select’ operations are already vectorized. Maybe a sequence of inst-combines (or DAG-combines) can help. If you re-write this code using scalars then the slp-vectorizer, with some tweaks, will be able to catch it. 
>> 
> 
> I've tried manually scalarizing the arguments so the other select arguments are scalars, but the vectorizer still doesn't change it. Here is the scalarized IR.
> 
> <manual_scalarize.ll>





More information about the llvm-dev mailing list