[Mlir-commits] [flang] [mlir] [MLIR][OpenMP] Fix type mismatch in linear clause for INTEGER(8) variables (PR #173982)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Jan 1 10:10:48 PST 2026


================
@@ -187,17 +187,37 @@ class LinearClauseProcessor {
                        llvm::Value *loopInductionVar) {
     builder.SetInsertPoint(loopBody->getTerminator());
     for (size_t index = 0; index < linearPreconditionVars.size(); index++) {
-      // Emit increments for linear vars
-      llvm::LoadInst *linearVarStart = builder.CreateLoad(
-          linearVarTypes[index], linearPreconditionVars[index]);
-      auto mulInst = builder.CreateMul(loopInductionVar, linearSteps[index]);
-      if (linearVarTypes[index]->isIntegerTy()) {
-        auto addInst = builder.CreateAdd(linearVarStart, mulInst);
+      llvm::Type *linearVarType = linearVarTypes[index];
+      llvm::Value *iv = loopInductionVar;
+      llvm::Value *step = linearSteps[index];
+
+      if (!iv->getType()->isIntegerTy())
+        llvm_unreachable("OpenMP loop induction variable must be an integer "
+                         "type");
+
+      if (linearVarType->isIntegerTy()) {
+        // Integer path: normalize all arithmetic to linearVarType
+        iv = builder.CreateSExtOrTrunc(iv, linearVarType);
----------------
NimishMishra wrote:

Would a single `step = builder.CreateSExtOrTrunc(step, iv->getType());` not work here, like the Float path below?

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


More information about the Mlir-commits mailing list