[llvm] r335032 - [SLPVectorizer] Pull out AltOpcode determination from reorderAltShuffleOperands.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 19 02:16:06 PDT 2018


Author: rksimon
Date: Tue Jun 19 02:16:06 2018
New Revision: 335032

URL: http://llvm.org/viewvc/llvm-project?rev=335032&view=rev
Log:
[SLPVectorizer] Pull out AltOpcode determination from reorderAltShuffleOperands.

Minor step towards making the alternate opcode system work with a wider range of opcode pairs.

Modified:
    llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp

Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=335032&r1=335031&r2=335032&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Tue Jun 19 02:16:06 2018
@@ -645,7 +645,8 @@ private:
 
   /// \reorder commutative operands in alt shuffle if they result in
   ///  vectorized code.
-  void reorderAltShuffleOperands(unsigned Opcode, ArrayRef<Value *> VL,
+  void reorderAltShuffleOperands(unsigned Opcode, unsigned AltOpcode,
+                                 ArrayRef<Value *> VL,
                                  SmallVectorImpl<Value *> &Left,
                                  SmallVectorImpl<Value *> &Right);
 
@@ -1917,7 +1918,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Val
       // Reorder operands if reordering would enable vectorization.
       if (isa<BinaryOperator>(VL0)) {
         ValueList Left, Right;
-        reorderAltShuffleOperands(S.Opcode, VL, Left, Right);
+        unsigned AltOpcode = getAltOpcode(S.Opcode);
+        reorderAltShuffleOperands(S.Opcode, AltOpcode, VL, Left, Right);
         buildTree_rec(Left, Depth + 1, UserTreeIdx);
         buildTree_rec(Right, Depth + 1, UserTreeIdx);
         return;
@@ -2649,11 +2651,11 @@ int BoUpSLP::getGatherCost(ArrayRef<Valu
 // load a[3] + load b[3]
 // Reordering the second load b[1]  load a[1] would allow us to vectorize this
 // code.
-void BoUpSLP::reorderAltShuffleOperands(unsigned Opcode, ArrayRef<Value *> VL,
+void BoUpSLP::reorderAltShuffleOperands(unsigned Opcode, unsigned AltOpcode,
+                                        ArrayRef<Value *> VL,
                                         SmallVectorImpl<Value *> &Left,
                                         SmallVectorImpl<Value *> &Right) {
   // Push left and right operands of binary operation into Left and Right
-  unsigned AltOpcode = getAltOpcode(Opcode);
   (void)AltOpcode;
   for (Value *V : VL) {
     auto *I = cast<Instruction>(V);
@@ -3492,7 +3494,8 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
       ValueList LHSVL, RHSVL;
       assert(Instruction::isBinaryOp(S.Opcode) &&
              "Invalid Shuffle Vector Operand");
-      reorderAltShuffleOperands(S.Opcode, E->Scalars, LHSVL, RHSVL);
+      unsigned AltOpcode = getAltOpcode(S.Opcode);
+      reorderAltShuffleOperands(S.Opcode, AltOpcode, E->Scalars, LHSVL, RHSVL);
       setInsertPointAfterBundle(E->Scalars, VL0);
 
       Value *LHS = vectorizeTree(LHSVL);
@@ -3507,7 +3510,6 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
       Value *V0 = Builder.CreateBinOp(
           static_cast<Instruction::BinaryOps>(S.Opcode), LHS, RHS);
 
-      unsigned AltOpcode = getAltOpcode(S.Opcode);
       // Create a vector of LHS op2 RHS
       Value *V1 = Builder.CreateBinOp(
           static_cast<Instruction::BinaryOps>(AltOpcode), LHS, RHS);




More information about the llvm-commits mailing list