Skip to content

Commit 8cc731d

Browse files
committed
Use ConstantExpr::getBinOpIdentity
Created using spr 1.3.5
1 parent bb766b2 commit 8cc731d

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9959,13 +9959,9 @@ class InstructionsCompatibilityAnalysis {
99599959
/// MainOpcode. For Add, returns 0. For Or, it should choose between false and
99609960
/// the operand itself, since V or V == V.
99619961
Value *selectBestIdempotentValue() const {
9962-
switch (MainOpcode) {
9963-
case Instruction::Add:
9964-
return ConstantInt::getNullValue(MainOp->getType());
9965-
default:
9966-
break;
9967-
}
9968-
llvm_unreachable("Unsupported opcode");
9962+
assert(MainOpcode == Instruction::Add && "Unsupported opcode");
9963+
return ConstantExpr::getBinOpIdentity(MainOpcode, MainOp->getType(),
9964+
!MainOp->isCommutative());
99699965
}
99709966

99719967
/// Returns the value and operands for the \p V, considering if it is original

0 commit comments

Comments
 (0)