[SLP] use reduction kind's opcode to create new instructions; NFC

Similar to 5a1d31a28 -
This should be no-functional-change because the reduction kind
opcodes are 1-for-1 mappings to the instructions we are matching
as reductions. But we want to remove the need for the
`OperationData` opcode field because that does not work when
we start matching intrinsics (eg, maxnum) as reduction candidates.
This commit is contained in:
Sanjay Patel 2021-01-06 14:10:40 -05:00
parent 5d24089a70
commit 4c022b5a41
1 changed files with 2 additions and 5 deletions

View File

@ -6457,6 +6457,7 @@ class HorizontalReduction {
Value *createOp(IRBuilder<> &Builder, Value *LHS, Value *RHS,
const Twine &Name) const {
assert(isVectorizable() && "Unhandled reduction operation.");
unsigned RdxOpcode = RecurrenceDescriptor::getOpcode(Kind);
switch (Kind) {
case RecurKind::Add:
case RecurKind::Mul:
@ -6465,26 +6466,22 @@ class HorizontalReduction {
case RecurKind::Xor:
case RecurKind::FAdd:
case RecurKind::FMul:
return Builder.CreateBinOp((Instruction::BinaryOps)Opcode, LHS, RHS,
return Builder.CreateBinOp((Instruction::BinaryOps)RdxOpcode, LHS, RHS,
Name);
case RecurKind::SMax: {
assert(Opcode == Instruction::ICmp && "Expected integer types.");
Value *Cmp = Builder.CreateICmpSGT(LHS, RHS, Name);
return Builder.CreateSelect(Cmp, LHS, RHS, Name);
}
case RecurKind::SMin: {
assert(Opcode == Instruction::ICmp && "Expected integer types.");
Value *Cmp = Builder.CreateICmpSLT(LHS, RHS, Name);
return Builder.CreateSelect(Cmp, LHS, RHS, Name);
}
case RecurKind::UMax: {
assert(Opcode == Instruction::ICmp && "Expected integer types.");
Value *Cmp = Builder.CreateICmpUGT(LHS, RHS, Name);
return Builder.CreateSelect(Cmp, LHS, RHS, Name);
}
case RecurKind::UMin: {
assert(Opcode == Instruction::ICmp && "Expected integer types.");
Value *Cmp = Builder.CreateICmpULT(LHS, RHS, Name);
return Builder.CreateSelect(Cmp, LHS, RHS, Name);
}