[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation directive and "looprange" clause (PR #139293)

Walter J.T.V via cfe-commits cfe-commits at lists.llvm.org
Wed May 21 06:51:17 PDT 2025


================
@@ -0,0 +1,186 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -fopenmp -fopenmp-version=60 -fsyntax-only -Wuninitialized -verify %s
+
+void func() {
+
+    // expected-error at +2 {{statement after '#pragma omp fuse' must be a loop sequence containing canonical loops or loop-generating constructs}}
+    #pragma omp fuse 
+    ;
+
+    // expected-error at +2 {{statement after '#pragma omp fuse' must be a for loop}}
+    #pragma omp fuse 
+    {int bar = 0;}
+
+    // expected-error at +4 {{statement after '#pragma omp fuse' must be a for loop}}
+    #pragma omp fuse 
+    {
+        for(int i = 0; i < 10; ++i);
+        int x = 2;
+    }
+
+    // expected-error at +2 {{statement after '#pragma omp fuse' must be a loop sequence containing canonical loops or loop-generating constructs}}
+    #pragma omp fuse 
+    #pragma omp for 
+    for (int i = 0; i < 7; ++i)
+        ;
+
+    {
+        // expected-error at +2 {{expected statement}}
+        #pragma omp fuse
+    }
+
+    // expected-warning at +1 {{extra tokens at the end of '#pragma omp fuse' are ignored}}
+    #pragma omp fuse foo
+    {
+        for (int i = 0; i < 7; ++i)
+            ;
+        for(int j = 0; j < 100; ++j);
+
+    }
+
+
+    // expected-error at +1 {{unexpected OpenMP clause 'final' in directive '#pragma omp fuse'}}
+    #pragma omp fuse final(0) 
+    {
+        for (int i = 0; i < 7; ++i)
+            ;
+        for(int j = 0; j < 100; ++j);
+
+    }
+
+    //expected-error at +4 {{loop after '#pragma omp fuse' is not in canonical form}}
----------------
eZWALT wrote:

Is not that i need it, is that is emitted independently from the 1st one. I've simply added the first one, the 2nd is emitted probably from some CheckOpenMPLoop or other constraint checking function. Nevertheless, it is nice to have such detailed information althought i understand that in the tradeoff, it can result a bit verbose.

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


More information about the cfe-commits mailing list