[Mlir-commits] [mlir] [mlir][OpenMP] Fix update of linear iteration variables (PR #183800)
Tom Eccles
llvmlistbot at llvm.org
Tue Jul 21 09:51:21 PDT 2026
================
@@ -189,6 +190,26 @@ class LinearClauseProcessor {
}
}
+ // Find linear iteration variable and save it for later updates
+ void 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.
+ 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()) {
+ linearLoopIV = linearVar;
+ break;
----------------
tblah wrote:
I think it would be okay to stick with this patch and just add an error for this case. Maybe I was too strong in suggesting an MLIR verifier error - this could perhaps be a translation error (ideally all valid MLIR can be translated, but that could make things much harder than they need to be...).
So then if some frontend generates this IR we can't understand, we at least crash rather than generate potentially invalid code.
(2) is the most correct solution IMO but I can understand why you don't want to do all of that.
If you would prefer to do (3) rather than my suggestion then that is okay by me.
https://github.com/llvm/llvm-project/pull/183800
More information about the Mlir-commits
mailing list