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

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Oct 20 18:51:43 PDT 2026


================
@@ -172,6 +172,16 @@ static bool isStrictSubset(const VariantMatchInfo &VMI0,
   for (unsigned Bit : VMI0.RequiredTraits.set_bits())
     if (!VMI1.RequiredTraits.test(Bit))
       return false;
+  // Different runtime conditions share a trait, so compare them as well.
+  // A runtime condition can be left out of the traits but keep its key.
+  if (!VMI0.UserCondition.empty() && VMI0.UserCondition != VMI1.UserCondition)
----------------
MattPD wrote:

Could `isStrictSubset` count a retained condition when its trait has been removed from `RequiredTraits`? The first and third WHEN selectors in this reproducer are identical. The first WHEN remains applicable through `vendor(llvm)` even when `a` is false. [The base](https://github.com/llvm/llvm-project/commit/6278453680db4f0058ca12663f87b84c1b914ea4) emits unconditional TASKYIELD. The reviewed head instead emits TASKWAIT when `a` is false and `command_argument_count()` is positive.

You can reproduce this by saving the following as `repro.f90` and running `flang -fopenmp -fopenmp-version=52 -S -emit-llvm repro.f90 -o -`:

```fortran
subroutine same_condition(a)
  logical, intent(in) :: a
  !$omp metadirective &
  !$omp& when(user={condition(a)}, &
  !$omp& implementation={vendor(score(2): llvm), extension(match_any)}: taskyield) &
  !$omp& when(user={condition(command_argument_count() > 0)}, &
  !$omp& implementation={vendor(score(2): llvm)}: taskwait) &
  !$omp& when(user={condition(a)}, &
  !$omp& implementation={vendor(score(2): llvm), extension(match_any)}: barrier)
end subroutine
```

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


More information about the llvm-branch-commits mailing list