[Mlir-commits] [flang] [mlir] [flang][mlir][OpenMP] Add support for uniform clause in declare simd (PR #176046)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jan 19 09:53:32 PST 2026


================
@@ -1446,6 +1446,38 @@ void OmpStructureChecker::Enter(const parser::OpenMPDeclareSimdConstruct &x) {
   const parser::OmpDirectiveName &dirName{x.v.DirName()};
   PushContextAndClauseSets(dirName.source, dirName.v);
 
+  const Scope &containingScope = context_.FindScope(dirName.source);
+  const Scope &progUnitScope = GetProgramUnitContaining(containingScope);
+
+  for (const parser::OmpClause &clause : x.v.Clauses().v) {
+    llvm::omp::Clause id{clause.Id()};
+    if (id != llvm::omp::Clause::OMPC_uniform) {
+      continue;
----------------
chichunchen wrote:

Yes, we already generate error for inappropriate clauses. (below are the first two lines in `void OmpStructureChecker::Enter(const parser::OpenMPDeclareSimdConstruct &x)`).
```
  const parser::OmpDirectiveName &dirName{x.v.DirName()};
  PushContextAndClauseSets(dirName.source, dirName.v);
```

Flang pass below test with and without my change:
```
! RUN: %python %S/../test_errors.py %s %flang -fopenmp

subroutine bad_clause_on_declare_simd(x)
  integer :: x
  !ERROR: PRIVATE clause is not allowed on the DECLARE SIMD directive
  !$omp declare simd private(x)
end subroutine bad_clause_on_declare_simd

subroutine bad_uniform_on_parallel(x)
  integer :: x
  !ERROR: UNIFORM clause is not allowed on the PARALLEL directive
  !$omp parallel uniform(x)
  !$omp end parallel
end subroutine bad_uniform_on_parallel

end
```

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


More information about the Mlir-commits mailing list