[llvm-branch-commits] [llvm] 58b6c5d - [LoopUtils] reorder logic for creating reduction; NFC
Sanjay Patel via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jan 4 13:09:12 PST 2021
Author: Sanjay Patel
Date: 2021-01-04T16:05:02-05:00
New Revision: 58b6c5d932a0d435ddfd13f4f5b011207e64297f
URL: https://github.com/llvm/llvm-project/commit/58b6c5d932a0d435ddfd13f4f5b011207e64297f
DIFF: https://github.com/llvm/llvm-project/commit/58b6c5d932a0d435ddfd13f4f5b011207e64297f.diff
LOG: [LoopUtils] reorder logic for creating reduction; NFC
If we are using a shuffle reduction, we don't need to
go through the switch on opcode - return early.
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 96f1d4219bac..e062eacf82b2 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -982,6 +982,15 @@ Value *llvm::createSimpleTargetReduction(IRBuilderBase &Builder,
unsigned Opcode, Value *Src,
RecurKind RdxKind,
ArrayRef<Value *> RedOps) {
+ TargetTransformInfo::ReductionFlags RdxFlags;
+ RdxFlags.IsMaxOp = RdxKind == RecurKind::SMax ||
+ RdxKind == RecurKind::UMax ||
+ RdxKind == RecurKind::FMax;
+ RdxFlags.IsSigned = RdxKind == RecurKind::SMax || RdxKind == RecurKind::SMin;
+ if (!ForceReductionIntrinsic &&
+ !TTI->useReductionIntrinsic(Opcode, Src->getType(), RdxFlags))
+ return getShuffleReduction(Builder, Src, Opcode, RdxKind, RedOps);
+
auto *SrcVTy = cast<VectorType>(Src->getType());
std::function<Value *()> BuildFunc;
@@ -1044,15 +1053,7 @@ Value *llvm::createSimpleTargetReduction(IRBuilderBase &Builder,
default:
llvm_unreachable("Unhandled opcode");
}
- TargetTransformInfo::ReductionFlags RdxFlags;
- RdxFlags.IsMaxOp = RdxKind == RecurKind::SMax ||
- RdxKind == RecurKind::UMax ||
- RdxKind == RecurKind::FMax;
- RdxFlags.IsSigned = RdxKind == RecurKind::SMax || RdxKind == RecurKind::SMin;
- if (ForceReductionIntrinsic ||
- TTI->useReductionIntrinsic(Opcode, Src->getType(), RdxFlags))
- return BuildFunc();
- return getShuffleReduction(Builder, Src, Opcode, RdxKind, RedOps);
+ return BuildFunc();
}
Value *llvm::createTargetReduction(IRBuilderBase &B,
More information about the llvm-branch-commits
mailing list