[llvm] [LoopUnroll] Introduce parallel accumulators when unrolling FP reductions. (PR #166630)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 6 04:09:31 PST 2025
================
@@ -1256,14 +1257,19 @@ llvm::canParallelizeReductionWhenUnrolling(PHINode &Phi, Loop *L,
return std::nullopt;
RecurKind RK = RdxDesc.getRecurrenceKind();
// Skip unsupported reductions.
- // TODO: Handle additional reductions, including FP and min-max
- // reductions.
- if (!RecurrenceDescriptor::isIntegerRecurrenceKind(RK) ||
+ // TODO: Handle additional reductions, including min-max reductions.
+ if (!(RecurrenceDescriptor::isIntegerRecurrenceKind(RK) ||
+ RecurrenceDescriptor::isFloatingPointRecurrenceKind(RK)) ||
RecurrenceDescriptor::isAnyOfRecurrenceKind(RK) ||
RecurrenceDescriptor::isFindIVRecurrenceKind(RK) ||
RecurrenceDescriptor::isMinMaxRecurrenceKind(RK))
return std::nullopt;
+ if (RecurrenceDescriptor::isFloatingPointRecurrenceKind(RK)) {
+ if (!RdxDesc.getFastMathFlags().allowReassoc())
+ return std::nullopt;
+ }
----------------
fhahn wrote:
Do we need the check here? I *think* the recurrence descriptor analysis should take care of checking the required fast-math flags (in `RecurrenceDescriptor::isRecurrenceInstr`), and return RecurKind::None, if the required flags are missing.
https://github.com/llvm/llvm-project/pull/166630
More information about the llvm-commits
mailing list