Author: Sanjay Patel Date: 2020-12-02T09:04:08-05:00 New Revision: 56fd29e93bd133d354e7e639bca1c025162e91ac
URL: https://github.com/llvm/llvm-project/commit/56fd29e93bd133d354e7e639bca1c025162e91ac DIFF: https://github.com/llvm/llvm-project/commit/56fd29e93bd133d354e7e639bca1c025162e91ac.diff LOG: [SLP] use 'match' for binop/select; NFC This might be a small improvement in readability, but the real motivation is to make it easier to adapt the code to deal with intrinsics like 'maxnum' and/or integer min/max. There is potentially help in doing that with D92086, but we might also just add specialized wrappers here to deal with the expected patterns. Added: Modified: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp Removed: ################################################################################ diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index bfec51f0ada6..66d736974fbc 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -7463,9 +7463,10 @@ static bool tryToVectorizeHorReductionOrInstOperands( Instruction *Inst; unsigned Level; std::tie(Inst, Level) = Stack.pop_back_val(); - auto *BI = dyn_cast<BinaryOperator>(Inst); - auto *SI = dyn_cast<SelectInst>(Inst); - if (BI || SI) { + Value *B0, *B1; + bool IsBinop = match(Inst, m_BinOp(m_Value(B0), m_Value(B1))); + bool IsSelect = match(Inst, m_Select(m_Value(), m_Value(), m_Value())); + if (IsBinop || IsSelect) { HorizontalReduction HorRdx; if (HorRdx.matchAssociativeReduction(P, Inst)) { if (HorRdx.tryToReduce(R, TTI)) { @@ -7476,10 +7477,10 @@ static bool tryToVectorizeHorReductionOrInstOperands( continue; } } - if (P && BI) { - Inst = dyn_cast<Instruction>(BI->getOperand(0)); + if (P && IsBinop) { + Inst = dyn_cast<Instruction>(B0); if (Inst == P) - Inst = dyn_cast<Instruction>(BI->getOperand(1)); + Inst = dyn_cast<Instruction>(B1); if (!Inst) { // Set P to nullptr to avoid re-analysis of phi node in // matchAssociativeReduction function unless this is the root node. _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits