diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index f3a0baa00267d..bba6ddc87afb7 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -6475,15 +6475,20 @@ class HorizontalReduction { /// Checks if the reduction operation can be vectorized. bool isVectorizable() const { - // We currently only support add/mul/logical && min/max reductions. - return ((Kind == RK_Arithmetic && - (Opcode == Instruction::Add || Opcode == Instruction::FAdd || - Opcode == Instruction::Mul || Opcode == Instruction::FMul || - Opcode == Instruction::And || Opcode == Instruction::Or || - Opcode == Instruction::Xor)) || - (Opcode == Instruction::ICmp && - (Kind == RK_SMin || Kind == RK_SMax || - Kind == RK_UMin || Kind == RK_UMax))); + switch (Kind) { + case RK_Arithmetic: + return Opcode == Instruction::Add || Opcode == Instruction::FAdd || + Opcode == Instruction::Mul || Opcode == Instruction::FMul || + Opcode == Instruction::And || Opcode == Instruction::Or || + Opcode == Instruction::Xor; + case RK_SMin: + case RK_SMax: + case RK_UMin: + case RK_UMax: + return Opcode == Instruction::ICmp; + default: + return false; + } } /// Creates reduction operation with the current opcode.