Skip to content

Commit 6b22e39

Browse files
authored
[SLP] NFC. Remove the useless check for alternate instruction. (#117116)
Only BinaryOperator and CastInst support alternate instruction. It always returns false for TreeEntry::isAltShuffle if an instruction is ExtractElementInst, ExtractValueInst, LoadInst, StoreInst or InsertElementInst.
1 parent bd15c7c commit 6b22e39

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,9 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
975975
Type *Ty1 = Inst->getOperand(0)->getType();
976976
if (Ty0 == Ty1) {
977977
assert(InstOpcode == Opcode && "Expected same CmpInst opcode.");
978+
assert(InstOpcode == AltOpcode &&
979+
"Alternate instructions are only supported by BinaryOperator "
980+
"and CastInst.");
978981
// Check for compatible operands. If the corresponding operands are not
979982
// compatible - need to perform alternate vectorization.
980983
CmpInst::Predicate CurrentPred = Inst->getPredicate();
@@ -1003,7 +1006,10 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
10031006
AltPred == CurrentPred || AltPred == SwappedCurrentPred)
10041007
continue;
10051008
}
1006-
} else if (InstOpcode == Opcode || InstOpcode == AltOpcode) {
1009+
} else if (InstOpcode == Opcode) {
1010+
assert(InstOpcode == AltOpcode &&
1011+
"Alternate instructions are only supported by BinaryOperator and "
1012+
"CastInst.");
10071013
if (auto *Gep = dyn_cast<GetElementPtrInst>(I)) {
10081014
if (Gep->getNumOperands() != 2 ||
10091015
Gep->getOperand(0)->getType() != IBase->getOperand(0)->getType())
@@ -5999,8 +6005,10 @@ void BoUpSLP::reorderTopToBottom() {
59996005
if ((TE->State == TreeEntry::Vectorize ||
60006006
TE->State == TreeEntry::StridedVectorize) &&
60016007
isa<ExtractElementInst, ExtractValueInst, LoadInst, StoreInst,
6002-
InsertElementInst>(TE->getMainOp()) &&
6003-
!TE->isAltShuffle()) {
6008+
InsertElementInst>(TE->getMainOp())) {
6009+
assert(!TE->isAltShuffle() &&
6010+
"Alternate instructions are only supported by BinaryOperator "
6011+
"and CastInst.");
60046012
// Build correct orders for extract{element,value}, loads and
60056013
// stores.
60066014
reorderOrder(TE->ReorderIndices, Mask);

0 commit comments

Comments
 (0)