[llvm] [SLPVectorizer] Refactor HorizontalReduction::createOp (NFC) (PR #121549)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 9 07:49:34 PST 2025
================
@@ -19401,38 +19401,24 @@ class HorizontalReduction {
case RecurKind::FMul:
return Builder.CreateBinOp((Instruction::BinaryOps)RdxOpcode, LHS, RHS,
Name);
- case RecurKind::FMax:
- return Builder.CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS);
- case RecurKind::FMin:
- return Builder.CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS);
- case RecurKind::FMaximum:
- return Builder.CreateBinaryIntrinsic(Intrinsic::maximum, LHS, RHS);
- case RecurKind::FMinimum:
- return Builder.CreateBinaryIntrinsic(Intrinsic::minimum, LHS, RHS);
case RecurKind::SMax:
- if (UseSelect) {
- Value *Cmp = Builder.CreateICmpSGT(LHS, RHS, Name);
- return Builder.CreateSelect(Cmp, LHS, RHS, Name);
- }
- return Builder.CreateBinaryIntrinsic(Intrinsic::smax, LHS, RHS);
case RecurKind::SMin:
- if (UseSelect) {
- Value *Cmp = Builder.CreateICmpSLT(LHS, RHS, Name);
- return Builder.CreateSelect(Cmp, LHS, RHS, Name);
- }
- return Builder.CreateBinaryIntrinsic(Intrinsic::smin, LHS, RHS);
case RecurKind::UMax:
+ case RecurKind::UMin: {
if (UseSelect) {
- Value *Cmp = Builder.CreateICmpUGT(LHS, RHS, Name);
- return Builder.CreateSelect(Cmp, LHS, RHS, Name);
- }
- return Builder.CreateBinaryIntrinsic(Intrinsic::umax, LHS, RHS);
- case RecurKind::UMin:
- if (UseSelect) {
- Value *Cmp = Builder.CreateICmpULT(LHS, RHS, Name);
+ CmpInst::Predicate Pred = llvm::getMinMaxReductionPredicate(Kind);
+ Value *Cmp = Builder.CreateICmp(Pred, LHS, RHS, Name);
return Builder.CreateSelect(Cmp, LHS, RHS, Name);
}
- return Builder.CreateBinaryIntrinsic(Intrinsic::umin, LHS, RHS);
+ }
----------------
alexey-bataev wrote:
Drop extra braces
https://github.com/llvm/llvm-project/pull/121549
More information about the llvm-commits
mailing list