@@ -982,6 +982,15 @@ Value *llvm::createSimpleTargetReduction(IRBuilderBase &Builder,
982
982
unsigned Opcode, Value *Src,
983
983
RecurKind RdxKind,
984
984
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
+
985
994
auto *SrcVTy = cast<VectorType>(Src->getType ());
986
995
987
996
std::function<Value *()> BuildFunc;
@@ -1044,15 +1053,7 @@ Value *llvm::createSimpleTargetReduction(IRBuilderBase &Builder,
1044
1053
default :
1045
1054
llvm_unreachable (" Unhandled opcode" );
1046
1055
}
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 ();
1056
1057
}
1057
1058
1058
1059
Value *llvm::createTargetReduction (IRBuilderBase &B,
0 commit comments