[flang-commits] [flang] [flang][OpenMP] Lower DO and SIMD variants in metadirectives (PR #210810)

via flang-commits flang-commits at lists.llvm.org
Fri Jul 24 22:55:07 PDT 2026


================
@@ -6028,23 +6318,91 @@ static void genMetadirective(lower::AbstractConverter &converter,
     }
   }
 
+  const parser::OmpDirectiveSpecification *nestedLoopVariant = nullptr;
----------------
MattPD wrote:

`nestedLoopVariant` is chosen from any applicable loop candidate (and the fallback) before `selectBestCandidate` runs, so the check that emits `loop-associated METADIRECTIVE nested in an OpenMP data environment` (and the mixed block/loop TODO) depends on a loop candidate being present rather than selected. A metadirective that statically selects a non-loop variant but also lists a lower-ranked `do` then fails to compile, though the loop is never selected. For static selection, could these loop-only checks run after `selectBestCandidate` and apply only when the selected variant is loop-associated? Would the candidate-wide check still be needed for the runtime cascade?

Reproducer: inside `!$omp parallel`, `!$omp metadirective when(user={condition(score(2): .true.)}: barrier) when(user={condition(score(1): .true.)}: do) otherwise(nothing)` over a loop gives `not yet implemented: loop-associated METADIRECTIVE nested in an OpenMP data environment`. Removing the `do` candidate compiles to `omp.barrier`.

https://github.com/llvm/llvm-project/pull/210810


More information about the flang-commits mailing list