From 2a9352bad457eb43f9fdbe22a347a57bc9940e87 Mon Sep 17 00:00:00 2001 From: Mel Chen Date: Mon, 8 Jul 2024 04:13:21 -0700 Subject: [PATCH] Remove lambda --- llvm/lib/IR/VectorBuilder.cpp | 89 ++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 38 deletions(-) diff --git a/llvm/lib/IR/VectorBuilder.cpp b/llvm/lib/IR/VectorBuilder.cpp index 67e9975080f4e6..5ff30828798950 100644 --- a/llvm/lib/IR/VectorBuilder.cpp +++ b/llvm/lib/IR/VectorBuilder.cpp @@ -63,44 +63,57 @@ Value *VectorBuilder::createVectorInstruction(unsigned Opcode, Type *ReturnTy, Value *VectorBuilder::createSimpleTargetReduction(RecurKind Kind, Type *ValTy, ArrayRef InstOpArray, const Twine &Name) { - auto GetForRecurKind = [](RecurKind Kind) { - switch (Kind) { - case RecurKind::Add: - return Intrinsic::vp_reduce_add; - case RecurKind::Mul: - return Intrinsic::vp_reduce_mul; - case RecurKind::And: - return Intrinsic::vp_reduce_and; - case RecurKind::Or: - return Intrinsic::vp_reduce_or; - case RecurKind::Xor: - return Intrinsic::vp_reduce_xor; - case RecurKind::FMulAdd: - case RecurKind::FAdd: - return Intrinsic::vp_reduce_fadd; - case RecurKind::FMul: - return Intrinsic::vp_reduce_fmul; - case RecurKind::SMax: - return Intrinsic::vp_reduce_smax; - case RecurKind::SMin: - return Intrinsic::vp_reduce_smin; - case RecurKind::UMax: - return Intrinsic::vp_reduce_umax; - case RecurKind::UMin: - return Intrinsic::vp_reduce_umin; - case RecurKind::FMax: - return Intrinsic::vp_reduce_fmax; - case RecurKind::FMin: - return Intrinsic::vp_reduce_fmin; - case RecurKind::FMaximum: - return Intrinsic::vp_reduce_fmaximum; - case RecurKind::FMinimum: - return Intrinsic::vp_reduce_fminimum; - default: - llvm_unreachable("No VPIntrinsic for this reduction"); - } - }; - auto VPID = GetForRecurKind(Kind); + Intrinsic::ID VPID; + switch (Kind) { + case RecurKind::Add: + VPID = Intrinsic::vp_reduce_add; + break; + case RecurKind::Mul: + VPID = Intrinsic::vp_reduce_mul; + break; + case RecurKind::And: + VPID = Intrinsic::vp_reduce_and; + break; + case RecurKind::Or: + VPID = Intrinsic::vp_reduce_or; + break; + case RecurKind::Xor: + VPID = Intrinsic::vp_reduce_xor; + break; + case RecurKind::FMulAdd: + case RecurKind::FAdd: + VPID = Intrinsic::vp_reduce_fadd; + break; + case RecurKind::FMul: + VPID = Intrinsic::vp_reduce_fmul; + break; + case RecurKind::SMax: + VPID = Intrinsic::vp_reduce_smax; + break; + case RecurKind::SMin: + VPID = Intrinsic::vp_reduce_smin; + break; + case RecurKind::UMax: + VPID = Intrinsic::vp_reduce_umax; + break; + case RecurKind::UMin: + VPID = Intrinsic::vp_reduce_umin; + break; + case RecurKind::FMax: + VPID = Intrinsic::vp_reduce_fmax; + break; + case RecurKind::FMin: + VPID = Intrinsic::vp_reduce_fmin; + break; + case RecurKind::FMaximum: + VPID = Intrinsic::vp_reduce_fmaximum; + break; + case RecurKind::FMinimum: + VPID = Intrinsic::vp_reduce_fminimum; + break; + default: + llvm_unreachable("No VPIntrinsic for this reduction"); + } return createVectorInstructionImpl(VPID, ValTy, InstOpArray, Name); }