[flang-commits] [flang] [flang][openmp] Fix incorrect reduction for array section in OpenMP DO SIMD (PR #192394)
Sergio Afonso via flang-commits
flang-commits at lists.llvm.org
Thu Apr 30 02:48:14 PDT 2026
================
@@ -696,6 +699,21 @@ bool ReductionProcessor::processReductionArguments(
}
for (const semantics::Symbol *symbol : reductionSymbols) {
+ // If a cached reduction variable exists for this symbol, reuse it.
+ // This ensures that composite constructs (e.g. DO SIMD) where both
+ // the outer wrapper (wsloop) and inner wrapper (simd) process the same
+ // reduction clause share the same SSA value, enabling genLoopVars()'s
+ // IRMapping to correctly remap inner wrapper operands to outer wrapper
+ // block arguments.
+ if (reductionVarCache) {
+ auto it = reductionVarCache->find(symbol);
+ if (it != reductionVarCache->end()) {
+ reductionVars.push_back(it->second);
+ reduceVarByRef.push_back(doReductionByRef(it->second));
+ continue;
----------------
skatrak wrote:
My bad, somehow I misread this as having another loop the `continue` statement impacted. We indeed avoid multiple insertions, so things stay in sync. Thanks for the detailed explanation.
https://github.com/llvm/llvm-project/pull/192394
More information about the flang-commits
mailing list