diff options
-rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 054c0a2c6fa..1e23e706c13 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -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<Value *> VL, unsigned Depth, // 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<Value *> VL) { // 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 *E) { 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 *E) { 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); |