diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -6371,9 +6371,8 @@ /// Construction for reduced values. They are identified by opcode only and /// don't have associated LHS/RHS values. - explicit OperationData(Value *V) { - if (auto *I = dyn_cast(V)) - Opcode = I->getOpcode(); + explicit OperationData(Instruction &I) { + Opcode = I.getOpcode(); } /// Constructor for reduction operations with opcode and its left and @@ -6631,17 +6630,17 @@ } } - static OperationData getOperationData(Value *V) { - if (!V) + static OperationData getOperationData(Instruction *I) { + if (!I) return OperationData(); Value *LHS; Value *RHS; - if (m_BinOp(m_Value(LHS), m_Value(RHS)).match(V)) { - return OperationData(cast(V)->getOpcode(), LHS, RHS, + if (m_BinOp(m_Value(LHS), m_Value(RHS)).match(I)) { + return OperationData(cast(I)->getOpcode(), LHS, RHS, RK_Arithmetic); } - if (auto *Select = dyn_cast(V)) { + if (auto *Select = dyn_cast(I)) { // Look for a min/max pattern. if (m_UMin(m_Value(LHS), m_Value(RHS)).match(Select)) { return OperationData(Instruction::ICmp, LHS, RHS, RK_UMin); @@ -6675,22 +6674,22 @@ if (match(Cond, m_Cmp(Pred, m_Specific(LHS), m_Instruction(L2)))) { if (!isa(RHS) || !L2->isIdenticalTo(cast(RHS))) - return OperationData(V); + return OperationData(*I); } else if (match(Cond, m_Cmp(Pred, m_Instruction(L1), m_Specific(RHS)))) { if (!isa(LHS) || !L1->isIdenticalTo(cast(LHS))) - return OperationData(V); + return OperationData(*I); } else { if (!isa(LHS) || !isa(RHS)) - return OperationData(V); + return OperationData(*I); if (!match(Cond, m_Cmp(Pred, m_Instruction(L1), m_Instruction(L2))) || !L1->isIdenticalTo(cast(LHS)) || !L2->isIdenticalTo(cast(RHS))) - return OperationData(V); + return OperationData(*I); } switch (Pred) { default: - return OperationData(V); + return OperationData(*I); case CmpInst::ICMP_ULT: case CmpInst::ICMP_ULE: @@ -6710,7 +6709,7 @@ } } } - return OperationData(V); + return OperationData(*I); } public: