[Mlir-commits] [mlir] a6385a3 - [mlir][OpenMP][NFC] use llvm::zip_equal for firstprivate copy region translation (#116416)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Nov 18 02:25:23 PST 2024
Author: Tom Eccles
Date: 2024-11-18T10:25:19Z
New Revision: a6385a3fc8a88f092d07672210a1e773481c2919
URL: https://github.com/llvm/llvm-project/commit/a6385a3fc8a88f092d07672210a1e773481c2919
DIFF: https://github.com/llvm/llvm-project/commit/a6385a3fc8a88f092d07672210a1e773481c2919.diff
LOG: [mlir][OpenMP][NFC] use llvm::zip_equal for firstprivate copy region translation (#116416)
I think this is a bit easier to read.
Added:
Modified:
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index a39b27aa9e12dc..4ee0222f9d6cf7 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());
More information about the Mlir-commits
mailing list