[llvm] [mlir] [llvm][OpenMP] Add implicit cast to omp.atomic.read (PR #114659)
Tom Eccles via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 4 02:48:05 PST 2024
================
@@ -265,6 +265,32 @@ computeOpenMPScheduleType(ScheduleKind ClauseKind, bool HasChunks,
return Result;
}
+/// Emit an implicit cast to convert \p XRead to type of variable \p V
+static llvm::Value *emitImplicitCast(IRBuilder<> &Builder, llvm::Value *XRead,
+ llvm::Value *V) {
+ llvm::Type *XReadType = XRead->getType();
+ llvm::Type *VType = V->getType();
+ if (llvm::AllocaInst *vAlloca = dyn_cast<llvm::AllocaInst>(V))
+ VType = vAlloca->getAllocatedType();
+
+ if (XReadType->isStructTy() && VType->isStructTy())
+ // No need to extract or convert. A direct
+ // `store` will suffice.
+ return XRead;
+
+ if (XRead->getType()->isStructTy())
+ XRead = Builder.CreateExtractValue(XRead, /*Idxs=*/0);
+ if (VType->isIntegerTy() && XReadType->isFloatingPointTy())
----------------
tblah wrote:
nit: I think this can be `else if`
https://github.com/llvm/llvm-project/pull/114659
More information about the llvm-commits
mailing list