Skip to content

Commit

Permalink
Remove lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
Mel-Chen committed Jul 8, 2024
1 parent 7f30bf6 commit 2a9352b
Showing 1 changed file with 51 additions and 38 deletions.
89 changes: 51 additions & 38 deletions llvm/lib/IR/VectorBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,44 +63,57 @@ Value *VectorBuilder::createVectorInstruction(unsigned Opcode, Type *ReturnTy,
Value *VectorBuilder::createSimpleTargetReduction(RecurKind Kind, Type *ValTy,
ArrayRef<Value *> 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);
}

Expand Down

0 comments on commit 2a9352b

Please sign in to comment.