From 4c022b5a41dee998ae50cdad4e8b6548acbeee9f Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Wed, 6 Jan 2021 14:10:40 -0500 Subject: [PATCH] [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. --- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index c4278722418b..7b77aef2a75c 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -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); }