[Mlir-commits] [mlir] [mlir][OpenMP] Fix update of linear iteration variables (PR #183800)

Tom Eccles llvmlistbot at llvm.org
Fri Jul 24 05:51:58 PDT 2026


================
@@ -191,23 +191,32 @@ class LinearClauseProcessor {
   }
 
   // Find linear iteration variable and save it for later updates
-  void initLinearIV(omp::SimdOp simdOp) {
+  LogicalResult initLinearIV(omp::SimdOp simdOp) {
     auto loopOp = cast<omp::LoopNestOp>(simdOp.getWrappedLoop());
     // NOTE iteration variables can only be linear in non-nested loops.
     if (loopOp.getIVs().size() != 1)
-      return;
-    // The linear IV is the loop IV's store address.
+      return success();
+    // Currently, frontends using `omp.simd` always generate a store from the
+    // `omp.loop_nest`'s IV to the corresponding iteration variable.
+    // We leverage this to find the linear iteration variable.
+    //
+    // TODO Add an attribute to `omp.loop_nest` that explicitly lists the
+    //      variables that correspond to the loop induction variables.
     BlockArgument arg = loopOp.getIVs().front();
     for (const Operation *user : arg.getUsers()) {
       if (auto storeOp = dyn_cast<LLVM::StoreOp>(user)) {
         for (Value linearVar : simdOp.getLinearVars()) {
           if (linearVar == storeOp.getAddr()) {
+            if (linearLoopIV)
----------------
tblah wrote:

nit: Maybe this could be relaxed to allow repeated stores to the same location

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


More information about the Mlir-commits mailing list