[PATCH] PR20234 - [SLP Vectorizer] Canonicalize operands of commutitive binary operands.

Nadav Rotem nrotem at apple.com
Tue Jul 29 14:18:58 PDT 2014


> On Jul 25, 2014, at 6:16 PM, Chad Rosier <mcrosier at codeaurora.org> wrote:
> 
>>> ! In D4680#5, @nadav wrote:
>> Chad, 
>> 
>> In this patch you are changing the instruction V regardless if vectorization succeeds or not. Would it be possible to only change the VL vector without modifying the binary operator V?  
>> 
>> Thanks,
>> Nadav
> 
> Nadav,
> That would be perfectly fine.  In fact, it's the right thing to do as we don't want to undo the canonicalization performed by the reassociation pass.
> 
> Chad

Hi Chad, 

Exactly!  The code should look like:

    if (IndexA > IndexB)
 	  swap(VL[0], VL[1]);

Thanks,
Nadav


> 
> ================
> Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:2425
> @@ +2424,3 @@
> +    if (IndexA > IndexB) {
> +      V->setOperand(0, B);
> +      V->setOperand(1, A);
> ----------------
> We don't need to actually modify the instruction for this to work.
> 
> http://reviews.llvm.org/D4680
> 
> 




More information about the llvm-commits mailing list