[clang] [flang] [llvm] [flang][OpenMP] Don't treat different runtime conditions as subsets (PR #233493)

via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 12 23:00:31 PST 2026


================
@@ -2635,6 +2656,10 @@ std::optional<MetadirectiveCandidateSet> BuildMetadirectiveCandidateSet(
       llvm::omp::VariantMatchInfo rawVMI;
       std::optional<DynamicUserCondition> dynamicCondition{
           MakeVariantMatchInfo(rawVMI, *ctxSel, context)};
+      // An omitted directive is ranked without its condition, except for its
+      // unguarded match_any candidate below.
+      if (dynamicCondition && isExplicit)
----------------
MattPD wrote:

Could the subset comparison retain the WHEN condition even when its directive is omitted? [The baseline](https://github.com/llvm/llvm-project/commit/9f63b3c669b726e020a1f2a63e23c47d8349356c) emits unconditional TASKWAIT, but the reviewed head emits TASKYIELD when `b` is true. Compile with `flang -fopenmp -fopenmp-version=52 -S -emit-llvm repro.f90 -o -`:
```fortran
subroutine three_clause(b)
  logical, intent(in) :: b
  !$omp metadirective when(user={condition(b)}: taskyield) &
  !$omp& when(user={condition(.true.)}, implementation={vendor(llvm)}: taskwait) &
  !$omp& when(user={condition(b)}, implementation={vendor(llvm)}:)
end subroutine
```
All raw scores are one. The first selector is a strict subset of the third, so OpenMP 5.2 section 7.3 gives it score zero. Section 7.4 then places explicit TASKWAIT before implicit NOTHING. Replacing only the omission with `nothing` emits unconditional TASKWAIT on both revisions.

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


More information about the cfe-commits mailing list