Skip to content

Commit 58b6c5d

Browse files
committed
[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.
1 parent 92be640 commit 58b6c5d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

llvm/lib/Transforms/Utils/LoopUtils.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,15 @@ Value *llvm::createSimpleTargetReduction(IRBuilderBase &Builder,
982982
unsigned Opcode, Value *Src,
983983
RecurKind RdxKind,
984984
ArrayRef<Value *> RedOps) {
985+
TargetTransformInfo::ReductionFlags RdxFlags;
986+
RdxFlags.IsMaxOp = RdxKind == RecurKind::SMax ||
987+
RdxKind == RecurKind::UMax ||
988+
RdxKind == RecurKind::FMax;
989+
RdxFlags.IsSigned = RdxKind == RecurKind::SMax || RdxKind == RecurKind::SMin;
990+
if (!ForceReductionIntrinsic &&
991+
!TTI->useReductionIntrinsic(Opcode, Src->getType(), RdxFlags))
992+
return getShuffleReduction(Builder, Src, Opcode, RdxKind, RedOps);
993+
985994
auto *SrcVTy = cast<VectorType>(Src->getType());
986995

987996
std::function<Value *()> BuildFunc;
@@ -1044,15 +1053,7 @@ Value *llvm::createSimpleTargetReduction(IRBuilderBase &Builder,
10441053
default:
10451054
llvm_unreachable("Unhandled opcode");
10461055
}
1047-
TargetTransformInfo::ReductionFlags RdxFlags;
1048-
RdxFlags.IsMaxOp = RdxKind == RecurKind::SMax ||
1049-
RdxKind == RecurKind::UMax ||
1050-
RdxKind == RecurKind::FMax;
1051-
RdxFlags.IsSigned = RdxKind == RecurKind::SMax || RdxKind == RecurKind::SMin;
1052-
if (ForceReductionIntrinsic ||
1053-
TTI->useReductionIntrinsic(Opcode, Src->getType(), RdxFlags))
1054-
return BuildFunc();
1055-
return getShuffleReduction(Builder, Src, Opcode, RdxKind, RedOps);
1056+
return BuildFunc();
10561057
}
10571058

10581059
Value *llvm::createTargetReduction(IRBuilderBase &B,

0 commit comments

Comments
 (0)