[flang-commits] [flang] [mlir] [llvm][mlir][OpenMP] Support translation for linear clause in omp.wsloop and omp.simd (PR #139386)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Thu Nov 6 04:37:52 PST 2025


================
@@ -114,19 +114,6 @@ llvm.func @sections_private(%x : !llvm.ptr) {
 }
 
 
-// -----
----------------
tblah wrote:

I'm not sure I understand the issue. Please could you give an example of what is missing?

The type attribute is visible in the IR. For example, I got this by running `tco -emit-final-mlir -simplify-mlir -O0` (and manually removing a few tbaa attributes):
```
  omp.private {type = private} @_QFsimple_linearEi_private_i32 : i32
  llvm.func @_QPsimple_linear() {
    %0 = llvm.mlir.constant(1 : i32) : i32
    %1 = llvm.mlir.constant(10 : i32) : i32
    %2 = llvm.mlir.constant(2 : i32) : i32
    %3 = llvm.mlir.constant(1 : i64) : i64
    %4 = llvm.alloca %3 x i32 {bindc_name = "y"} : (i64) -> !llvm.ptr
    %5 = llvm.alloca %3 x i32 {bindc_name = "x"} : (i64) -> !llvm.ptr
    %6 = llvm.alloca %3 x i32 {bindc_name = "i"} : (i64) -> !llvm.ptr
    omp.wsloop linear(%5 = %0 : !llvm.ptr) private(@_QFsimple_linearEi_private_i32 %6 -> %arg0 : !llvm.ptr) {
      omp.loop_nest (%arg1) : i32 = (%0) to (%1) inclusive step (%0) {
        llvm.store %arg1, %arg0 : i32, !llvm.ptr
        %7 = llvm.load %5 : !llvm.ptr -> i32
        %8 = llvm.add %7, %2 : i32
        llvm.store %8, %4 : i32, !llvm.ptr
        omp.yield
      }
    } {linear_var_types = [i32]}
    llvm.return
  }
```

Here the `{linear_var_types = [i32]}` is visible. This can be lowered to LLVM in a lit test using `mlir-translate --mlir-to-llvmir`.

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


More information about the flang-commits mailing list