Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp =================================================================== --- clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -4882,7 +4882,7 @@ bool HasRegularWithIterators = false; llvm::Value *NumOfDepobjElements = llvm::ConstantInt::get(CGF.IntPtrTy, 0); llvm::Value *NumOfRegularWithIterators = - llvm::ConstantInt::get(CGF.IntPtrTy, 1); + llvm::ConstantInt::get(CGF.IntPtrTy, 0); // Calculate number of depobj dependecies and regular deps with the iterators. for (const OMPTaskDataTy::DependData &D : Dependencies) { if (D.DepKind == OMPC_DEPEND_depobj) { @@ -4896,12 +4896,15 @@ continue; } // Include number of iterations, if any. + if (const auto *IE = cast_or_null(D.IteratorExpr)) { for (unsigned I = 0, E = IE->numOfIterators(); I < E; ++I) { llvm::Value *Sz = CGF.EmitScalarExpr(IE->getHelper(I).Upper); Sz = CGF.Builder.CreateIntCast(Sz, CGF.IntPtrTy, /*isSigned=*/false); + llvm::Value *NumClauseDeps = + CGF.Builder.CreateNUWMul(Sz, llvm::ConstantInt::get(CGF.IntPtrTy, D.DepExprs.size())); NumOfRegularWithIterators = - CGF.Builder.CreateNUWMul(NumOfRegularWithIterators, Sz); + CGF.Builder.CreateNUWAdd(NumOfRegularWithIterators, NumClauseDeps); } HasRegularWithIterators = true; continue;