@@ -1210,12 +1210,12 @@ MDNode *llvm::GetUnrollMetadata(MDNode *LoopID, StringRef Name) {
12101210std::optional<RecurrenceDescriptor>
12111211llvm::canParallelizeReductionWhenUnrolling (PHINode &Phi, Loop *L,
12121212 ScalarEvolution *SE) {
1213- RecurrenceDescriptor RedDes ;
1214- if (!RecurrenceDescriptor::isReductionPHI (&Phi, L, RedDes ,
1213+ RecurrenceDescriptor RdxDesc ;
1214+ if (!RecurrenceDescriptor::isReductionPHI (&Phi, L, RdxDesc ,
12151215 /* DemandedBits=*/ nullptr ,
12161216 /* AC=*/ nullptr , /* DT=*/ nullptr , SE))
12171217 return std::nullopt ;
1218- RecurKind RK = RedDes .getRecurrenceKind ();
1218+ RecurKind RK = RdxDesc .getRecurrenceKind ();
12191219 // Skip unsupported reductions.
12201220 // TODO: Handle additional reductions, including FP and min-max
12211221 // reductions.
@@ -1225,6 +1225,9 @@ llvm::canParallelizeReductionWhenUnrolling(PHINode &Phi, Loop *L,
12251225 RecurrenceDescriptor::isMinMaxRecurrenceKind (RK))
12261226 return std::nullopt ;
12271227
1228+ if (RdxDesc.IntermediateStore )
1229+ return std::nullopt ;
1230+
12281231 // Don't unroll reductions with constant ops; those can be folded to a
12291232 // single induction update.
12301233 if (any_of (cast<Instruction>(Phi.getIncomingValueForBlock (L->getLoopLatch ()))
@@ -1239,5 +1242,5 @@ llvm::canParallelizeReductionWhenUnrolling(PHINode &Phi, Loop *L,
12391242 &Phi))
12401243 return std::nullopt ;
12411244
1242- return RedDes ;
1245+ return RdxDesc ;
12431246}
0 commit comments