[Mlir-commits] [mlir] [mlir][OpenMP][NFC] use llvm::zip_equal for firstprivate copy region translation (PR #116416)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Nov 15 22:20:29 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-llvm
Author: Tom Eccles (tblah)
<details>
<summary>Changes</summary>
I think this is a bit easier to read.
---
Full diff: https://github.com/llvm/llvm-project/pull/116416.diff
1 Files Affected:
- (modified) mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp (+14-20)
``````````diff
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 5bf99535295c4f..6d942ddf68b1c5 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -1597,24 +1597,21 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
splitBB(builder, /*CreateBranch=*/true, "omp.private.copy");
builder.SetInsertPoint(copyBlock->getFirstNonPHIOrDbgOrAlloca());
}
- for (unsigned i = 0; i < privateBlockArgs.size(); ++i) {
- if (privateDecls[i].getDataSharingType() !=
- omp::DataSharingClauseType::FirstPrivate)
+ for (auto [decl, mlirVar, llvmVar] :
+ llvm::zip_equal(privateDecls, mlirPrivateVars, llvmPrivateVars)) {
+ if (decl.getDataSharingType() != omp::DataSharingClauseType::FirstPrivate)
continue;
// copyRegion implements `lhs = rhs`
- Region ©Region = privateDecls[i].getCopyRegion();
+ Region ©Region = decl.getCopyRegion();
// map copyRegion rhs arg
- llvm::Value *nonPrivateVar =
- moduleTranslation.lookupValue(taskOp.getPrivateVars()[i]);
+ llvm::Value *nonPrivateVar = moduleTranslation.lookupValue(mlirVar);
assert(nonPrivateVar);
- moduleTranslation.mapValue(privateDecls[i].getCopyMoldArg(),
- nonPrivateVar);
+ moduleTranslation.mapValue(decl.getCopyMoldArg(), nonPrivateVar);
// map copyRegion lhs arg
- moduleTranslation.mapValue(privateDecls[i].getCopyPrivateArg(),
- llvmPrivateVars[i]);
+ moduleTranslation.mapValue(decl.getCopyPrivateArg(), llvmVar);
// in-place convert copy region
builder.SetInsertPoint(builder.GetInsertBlock()->getTerminator());
@@ -1936,24 +1933,21 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
splitBB(builder, /*CreateBranch=*/true, "omp.private.copy");
builder.SetInsertPoint(copyBlock->getFirstNonPHIOrDbgOrAlloca());
}
- for (unsigned i = 0; i < privateBlockArgs.size(); ++i) {
- if (privateDecls[i].getDataSharingType() !=
- omp::DataSharingClauseType::FirstPrivate)
+ for (auto [decl, mlirVar, llvmVar] :
+ llvm::zip_equal(privateDecls, mlirPrivateVars, llvmPrivateVars)) {
+ if (decl.getDataSharingType() != omp::DataSharingClauseType::FirstPrivate)
continue;
// copyRegion implements `lhs = rhs`
- Region ©Region = privateDecls[i].getCopyRegion();
+ Region ©Region = decl.getCopyRegion();
// map copyRegion rhs arg
- llvm::Value *nonPrivateVar =
- moduleTranslation.lookupValue(opInst.getPrivateVars()[i]);
+ llvm::Value *nonPrivateVar = moduleTranslation.lookupValue(mlirVar);
assert(nonPrivateVar);
- moduleTranslation.mapValue(privateDecls[i].getCopyMoldArg(),
- nonPrivateVar);
+ moduleTranslation.mapValue(decl.getCopyMoldArg(), nonPrivateVar);
// map copyRegion lhs arg
- moduleTranslation.mapValue(privateDecls[i].getCopyPrivateArg(),
- llvmPrivateVars[i]);
+ moduleTranslation.mapValue(decl.getCopyPrivateArg(), llvmVar);
// in-place convert copy region
builder.SetInsertPoint(builder.GetInsertBlock()->getTerminator());
``````````
</details>
https://github.com/llvm/llvm-project/pull/116416
More information about the Mlir-commits
mailing list