================
@@ -172,7 +170,8 @@ static bool isStrictSubset(const VariantMatchInfo &VMI0,
   for (unsigned Bit : VMI0.RequiredTraits.set_bits())
     if (!VMI1.RequiredTraits.test(Bit))
       return false;
-  if (!isSubset<TraitProperty>(VMI0.ConstructTraits, VMI1.ConstructTraits))
+  if (!isOrderedSubset<TraitProperty>(VMI0.ConstructTraits,
----------------
MattPD wrote:

The `RequiredTraits.count()` guard makes `isStrictSubset` return false when 
only a repeated construct distinguishes the selectors. The new highest-valued 
match scoring can make such selectors tie, so the guard now determines whether 
the strict-subset tie-break applies.

Compiling the following reproducer with `flang -fopenmp -fopenmp-version=52 -S 
-emit-llvm repro.f90 -o -` emits TASKYIELD at b165f599 instead of the TASKWAIT 
selected by the [parent 
commit](https://github.com/llvm/llvm-project/commit/81b82b8012a2bf9a1f1822af10778922b4646fef):

```fortran
subroutine subset_first()
  integer :: i
  !$omp parallel
  !$omp parallel do
  do i = 1, 2
    !$omp metadirective &
    !$omp& when(construct={parallel do}, &
    !$omp& implementation={vendor(score(1): llvm)}: taskyield) &
    !$omp& when(construct={parallel, parallel do}, &
    !$omp& implementation={vendor(llvm)}: taskwait)
  end do
  !$omp end parallel do
  !$omp end parallel
end subroutine
```

Flang expands the construct selectors to `[parallel, do]` and `[parallel, 
parallel, do]`. Both now score 8. Their `RequiredTraits` counts are equal, so 
clause order decides the result. Reversing the clauses selects TASKWAIT.

Could the existing tie-break also recognize a strict subset from the ordered 
construct sequence, with tests covering both clause orders? The fix need not 
apply the strict-subset rule outside ties.

https://github.com/llvm/llvm-project/pull/231668
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to