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, _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits