[llvm] 5b3ba43 - Restructure createSimpleTargetReduction to match VP path [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 30 09:47:16 PDT 2024
Author: Philip Reames
Date: 2024-08-30T09:46:59-07:00
New Revision: 5b3ba438dfa7815bb0f3be07a300866085a431b9
URL: https://github.com/llvm/llvm-project/commit/5b3ba438dfa7815bb0f3be07a300866085a431b9
DIFF: https://github.com/llvm/llvm-project/commit/5b3ba438dfa7815bb0f3be07a300866085a431b9.diff
LOG: Restructure createSimpleTargetReduction to match VP path [NFC]
Reduces code significantly, but more importantly makes it obvious that
this variant matches the VP variant just below.
Added:
Modified:
llvm/lib/Transforms/Utils/LoopUtils.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index f1f2d522f1cbaa..a49d3b0b990bc7 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -1212,37 +1212,25 @@ Value *llvm::createSimpleTargetReduction(IRBuilderBase &Builder, Value *Src,
auto *SrcVecEltTy = cast<VectorType>(Src->getType())->getElementType();
switch (RdxKind) {
case RecurKind::Add:
- return Builder.CreateAddReduce(Src);
case RecurKind::Mul:
- return Builder.CreateMulReduce(Src);
case RecurKind::And:
- return Builder.CreateAndReduce(Src);
case RecurKind::Or:
- return Builder.CreateOrReduce(Src);
case RecurKind::Xor:
- return Builder.CreateXorReduce(Src);
- case RecurKind::FMulAdd:
- case RecurKind::FAdd:
- return Builder.CreateFAddReduce(ConstantFP::getNegativeZero(SrcVecEltTy),
- Src);
- case RecurKind::FMul:
- return Builder.CreateFMulReduce(ConstantFP::get(SrcVecEltTy, 1.0), Src);
case RecurKind::SMax:
- return Builder.CreateIntMaxReduce(Src, true);
case RecurKind::SMin:
- return Builder.CreateIntMinReduce(Src, true);
case RecurKind::UMax:
- return Builder.CreateIntMaxReduce(Src, false);
case RecurKind::UMin:
- return Builder.CreateIntMinReduce(Src, false);
case RecurKind::FMax:
- return Builder.CreateFPMaxReduce(Src);
case RecurKind::FMin:
- return Builder.CreateFPMinReduce(Src);
case RecurKind::FMinimum:
- return Builder.CreateFPMinimumReduce(Src);
case RecurKind::FMaximum:
- return Builder.CreateFPMaximumReduce(Src);
+ return Builder.CreateUnaryIntrinsic(getReductionIntrinsicID(RdxKind), Src);
+ case RecurKind::FMulAdd:
+ case RecurKind::FAdd:
+ return Builder.CreateFAddReduce(ConstantFP::getNegativeZero(SrcVecEltTy),
+ Src);
+ case RecurKind::FMul:
+ return Builder.CreateFMulReduce(ConstantFP::get(SrcVecEltTy, 1.0), Src);
default:
llvm_unreachable("Unhandled opcode");
}
More information about the llvm-commits
mailing list