[clang] [llvm] [Clang][OpenMP] Implement Loop splitting `#pragma omp split` directive (PR #183261)
Michael Kruse via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 19 04:13:38 PDT 2026
================
@@ -0,0 +1,44 @@
+/*
+ * Verify #pragma omp split counts(c1, c2, ...) at AST, IR, and runtime.
+ * counts(3, 5, 2) splits 10 iterations into: [0..3), [3..8), [8..10).
+ * Sum 0+1+...+9 = 45.
+ */
+// REQUIRES: x86-registered-target
+
+// 1) Syntax and semantics only
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// 2) AST dump should show OMPSplitDirective with OMPCountsClause node.
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-dump %s 2>&1 | FileCheck %s --check-prefix=AST
+
+// 3) Emit LLVM: three sequential loops (multiple phi/br for loop structure)
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -fopenmp-version=60 -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=IR
+
+// 4) Compile and run: exit 0 if sum == 45
+// RUN: %clang -fopenmp -fopenmp-version=60 -O0 %s -o %t.exe
+// RUN: %t.exe
----------------
Meinersbur wrote:
Tests in `clang/` must not be end2end. Since we might cross-compile clang (e.g. Building a Windows compiler on Linux), it might not be executable
Add a test to https://github.com/llvm/llvm-project/tree/main/openmp/runtime/test/transform for that.
https://github.com/llvm/llvm-project/pull/183261
More information about the cfe-commits
mailing list