@@ -17476,9 +17476,8 @@ class HorizontalReduction {
17476
17476
17477
17477
// Emit code to correctly handle reused reduced values, if required.
17478
17478
if (OptReusedScalars && !SameScaleFactor) {
17479
- VectorizedRoot =
17480
- emitReusedOps(VectorizedRoot, Builder, V.getRootNodeScalars(),
17481
- SameValuesCounter, TrackedToOrig);
17479
+ VectorizedRoot = emitReusedOps(VectorizedRoot, Builder, V,
17480
+ SameValuesCounter, TrackedToOrig);
17482
17481
}
17483
17482
17484
17483
Value *ReducedSubTree =
@@ -17818,24 +17817,19 @@ class HorizontalReduction {
17818
17817
/// Emits actual operation for the scalar identity values, found during
17819
17818
/// horizontal reduction analysis.
17820
17819
Value *emitReusedOps(Value *VectorizedValue, IRBuilderBase &Builder,
17821
- ArrayRef<Value *> VL ,
17820
+ BoUpSLP &R ,
17822
17821
const MapVector<Value *, unsigned> &SameValuesCounter,
17823
17822
const DenseMap<Value *, Value *> &TrackedToOrig) {
17824
17823
assert(IsSupportedHorRdxIdentityOp &&
17825
17824
"The optimization of matched scalar identity horizontal reductions "
17826
17825
"must be supported.");
17826
+ ArrayRef<Value *> VL = R.getRootNodeScalars();
17827
17827
auto *VTy = cast<FixedVectorType>(VectorizedValue->getType());
17828
17828
if (VTy->getElementType() != VL.front()->getType()) {
17829
17829
VectorizedValue = Builder.CreateIntCast(
17830
17830
VectorizedValue,
17831
17831
getWidenedType(VL.front()->getType(), VTy->getNumElements()),
17832
- any_of(VL, [&](Value *R) {
17833
- KnownBits Known = computeKnownBits(
17834
- R, cast<Instruction>(ReductionOps.front().front())
17835
- ->getModule()
17836
- ->getDataLayout());
17837
- return !Known.isNonNegative();
17838
- }));
17832
+ R.isSignedMinBitwidthRootNode());
17839
17833
}
17840
17834
switch (RdxKind) {
17841
17835
case RecurKind::Add: {
0 commit comments