From a634a07771b27a13d333ce5907adccb2931e53fc Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sun, 1 Jul 2018 20:22:46 +0000 Subject: [PATCH] [SLPVectorizer] Call InstructionsState.isOpcodeOrAlt with Instruction instead of an opcode. NFCI. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336069 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Vectorize/SLPVectorizer.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/Transforms/Vectorize/SLPVectorizer.cpp b/lib/Transforms/Vectorize/SLPVectorizer.cpp index c5088eb4800..1bca876bbbd 100644 --- a/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -313,7 +313,8 @@ struct InstructionsState { /// Some of the instructions in the list have alternate opcodes. bool isAltShuffle() const { return Opcode != AltOpcode; } - bool isOpcodeOrAlt(unsigned CheckedOpcode) const { + bool isOpcodeOrAlt(Instruction *I) const { + unsigned CheckedOpcode = I->getOpcode(); return Opcode == CheckedOpcode || AltOpcode == CheckedOpcode; } @@ -329,7 +330,7 @@ struct InstructionsState { /// OpValue. static Value *isOneOf(const InstructionsState &S, Value *Op) { auto *I = dyn_cast(Op); - if (I && S.isOpcodeOrAlt(I->getOpcode())) + if (I && S.isOpcodeOrAlt(I)) return Op; return S.OpValue; } @@ -2628,8 +2629,7 @@ void BoUpSLP::reorderAltShuffleOperands(const InstructionsState &S, // Push left and right operands of binary operation into Left and Right for (Value *V : VL) { auto *I = cast(V); - assert(S.isOpcodeOrAlt(I->getOpcode()) && - "Incorrect instruction in vector"); + assert(S.isOpcodeOrAlt(I) && "Incorrect instruction in vector"); Left.push_back(I->getOperand(0)); Right.push_back(I->getOperand(1)); } @@ -2837,8 +2837,8 @@ void BoUpSLP::setInsertPointAfterBundle(ArrayRef VL, auto *Front = cast(S.OpValue); auto *BB = Front->getParent(); assert(llvm::all_of(make_range(VL.begin(), VL.end()), [=](Value *V) -> bool { - return !S.isOpcodeOrAlt(cast(V)->getOpcode()) || - cast(V)->getParent() == BB; + auto *I = cast(V); + return !S.isOpcodeOrAlt(I) || I->getParent() == BB; })); // The last instruction in the bundle in program order. @@ -2878,7 +2878,7 @@ void BoUpSLP::setInsertPointAfterBundle(ArrayRef VL, if (!LastInst) { SmallPtrSet Bundle(VL.begin(), VL.end()); for (auto &I : make_range(BasicBlock::iterator(Front), BB->end())) { - if (Bundle.erase(&I) && S.isOpcodeOrAlt(I.getOpcode())) + if (Bundle.erase(&I) && S.isOpcodeOrAlt(&I)) LastInst = &I; if (Bundle.empty()) break; @@ -3490,10 +3490,8 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) { SmallVector Mask(e); for (unsigned i = 0; i < e; ++i) { auto *OpInst = cast(E->Scalars[i]); - unsigned InstOpcode = OpInst->getOpcode(); - assert(S.isOpcodeOrAlt(InstOpcode) && - "Unexpected main/alternate opcode"); - if (InstOpcode == S.AltOpcode) { + assert(S.isOpcodeOrAlt(OpInst) && "Unexpected main/alternate opcode"); + if (OpInst->getOpcode() == S.AltOpcode) { Mask[i] = Builder.getInt32(e + i); AltScalars.push_back(E->Scalars[i]); } else { -- 2.11.0