================
@@ -2579,6 +2585,24 @@ std::optional<MetadirectiveCandidateSet> 
BuildMetadirectiveCandidateSet(
     return spec.DirId() == llvm::omp::Directive::OMPD_nothing ? nullptr : 
&spec;
   };
 
+  // Identify each distinct runtime condition, so that different conditions
+  // are not strict subsets of each other.
+  llvm::SmallVector<SomeExpr, 4> runtimeConditions;
+  auto getConditionKey = [&](const DynamicUserCondition &condition) {
+    const SomeExpr *expr{GetExpr(context, *condition.expr)};
+    if (!expr ||
+        evaluate::IsActuallyConstant(
----------------
MattPD wrote:

Could `EvaluateUserCondition` and `getConditionKey` share the truth-value 
classification of folded logical constants? `EvaluateUserCondition` returns 
`nullopt` for `.false._8`, while `getConditionKey` recognizes it as constant. 
In this reproducer, [the 
base](https://github.com/llvm/llvm-project/commit/6278453680db4f0058ca12663f87b84c1b914ea4)
 emits unconditional TASKYIELD, but the reviewed head emits TASKWAIT when `b` 
is true.

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 false_constant(b)
  logical, intent(in) :: b
  !$omp metadirective &
  !$omp& when(device={kind(host)}, implementation={vendor(score(3): llvm)}: 
taskyield) &
  !$omp& when(user={condition(b)}, implementation={vendor(score(4): llvm)}: 
taskwait) &
  !$omp& when(user={condition(.false._8)}, device={kind(host)}, &
  !$omp& implementation={vendor(score(3): llvm)}: barrier)
end subroutine
```

Replacing `.false._8` with the default-kind literal `.false.` produces the same 
selection change under `-fdefault-integer-8`.

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

Reply via email to