@@ -8957,7 +8957,8 @@ OpenMPIRBuilder::createAtomicWrite(const LocationDescription &Loc,
89578957OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createAtomicUpdate (
89588958 const LocationDescription &Loc, InsertPointTy AllocaIP, AtomicOpValue &X,
89598959 Value *Expr, AtomicOrdering AO, AtomicRMWInst::BinOp RMWOp,
8960- AtomicUpdateCallbackTy &UpdateOp, bool IsXBinopExpr) {
8960+ AtomicUpdateCallbackTy &UpdateOp, bool IsXBinopExpr,
8961+ bool IsIgnoreDenormalMode, bool IsFineGrainedMemory, bool IsRemoteMemory) {
89618962 assert (!isConflictIP (Loc.IP , AllocaIP) && " IPs must not be ambiguous" );
89628963 if (!updateToLocation (Loc))
89638964 return Loc.IP ;
@@ -8975,9 +8976,9 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createAtomicUpdate(
89758976 " OpenMP atomic does not support LT or GT operations" );
89768977 });
89778978
8978- Expected<std::pair<Value *, Value *>> AtomicResult =
8979- emitAtomicUpdate ( AllocaIP, X.Var , X.ElemTy , Expr, AO, RMWOp, UpdateOp,
8980- X. IsVolatile , IsXBinopExpr );
8979+ Expected<std::pair<Value *, Value *>> AtomicResult = emitAtomicUpdate (
8980+ AllocaIP, X.Var , X.ElemTy , Expr, AO, RMWOp, UpdateOp, X. IsVolatile ,
8981+ IsXBinopExpr, IsIgnoreDenormalMode, IsFineGrainedMemory, IsRemoteMemory );
89818982 if (!AtomicResult)
89828983 return AtomicResult.takeError ();
89838984 checkAndEmitFlushAfterAtomic (Loc, AO, AtomicKind::Update);
@@ -9024,7 +9025,8 @@ Value *OpenMPIRBuilder::emitRMWOpAsInstruction(Value *Src1, Value *Src2,
90249025Expected<std::pair<Value *, Value *>> OpenMPIRBuilder::emitAtomicUpdate (
90259026 InsertPointTy AllocaIP, Value *X, Type *XElemTy, Value *Expr,
90269027 AtomicOrdering AO, AtomicRMWInst::BinOp RMWOp,
9027- AtomicUpdateCallbackTy &UpdateOp, bool VolatileX, bool IsXBinopExpr) {
9028+ AtomicUpdateCallbackTy &UpdateOp, bool VolatileX, bool IsXBinopExpr,
9029+ bool IsIgnoreDenormalMode, bool IsFineGrainedMemory, bool IsRemoteMemory) {
90289030 // TODO: handle the case where XElemTy is not byte-sized or not a power of 2
90299031 // or a complex datatype.
90309032 bool emitRMWOp = false ;
@@ -9047,7 +9049,20 @@ Expected<std::pair<Value *, Value *>> OpenMPIRBuilder::emitAtomicUpdate(
90479049
90489050 std::pair<Value *, Value *> Res;
90499051 if (emitRMWOp) {
9050- Res.first = Builder.CreateAtomicRMW (RMWOp, X, Expr, llvm::MaybeAlign (), AO);
9052+ AtomicRMWInst *RMWInst =
9053+ Builder.CreateAtomicRMW (RMWOp, X, Expr, llvm::MaybeAlign (), AO);
9054+ if (T.isAMDGPU ()) {
9055+ if (IsIgnoreDenormalMode)
9056+ RMWInst->setMetadata (" amdgpu.ignore.denormal.mode" ,
9057+ llvm::MDNode::get (Builder.getContext (), {}));
9058+ if (!IsFineGrainedMemory)
9059+ RMWInst->setMetadata (" amdgpu.no.fine.grained.memory" ,
9060+ llvm::MDNode::get (Builder.getContext (), {}));
9061+ if (!IsRemoteMemory)
9062+ RMWInst->setMetadata (" amdgpu.no.remote.memory" ,
9063+ llvm::MDNode::get (Builder.getContext (), {}));
9064+ }
9065+ Res.first = RMWInst;
90519066 // not needed except in case of postfix captures. Generate anyway for
90529067 // consistency with the else part. Will be removed with any DCE pass.
90539068 // AtomicRMWInst::Xchg does not have a coressponding instruction.
@@ -9179,7 +9194,8 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createAtomicCapture(
91799194 const LocationDescription &Loc, InsertPointTy AllocaIP, AtomicOpValue &X,
91809195 AtomicOpValue &V, Value *Expr, AtomicOrdering AO,
91819196 AtomicRMWInst::BinOp RMWOp, AtomicUpdateCallbackTy &UpdateOp,
9182- bool UpdateExpr, bool IsPostfixUpdate, bool IsXBinopExpr) {
9197+ bool UpdateExpr, bool IsPostfixUpdate, bool IsXBinopExpr,
9198+ bool IsIgnoreDenormalMode, bool IsFineGrainedMemory, bool IsRemoteMemory) {
91839199 if (!updateToLocation (Loc))
91849200 return Loc.IP ;
91859201
@@ -9198,9 +9214,9 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createAtomicCapture(
91989214 // If UpdateExpr is 'x' updated with some `expr` not based on 'x',
91999215 // 'x' is simply atomically rewritten with 'expr'.
92009216 AtomicRMWInst::BinOp AtomicOp = (UpdateExpr ? RMWOp : AtomicRMWInst::Xchg);
9201- Expected<std::pair<Value *, Value *>> AtomicResult =
9202- emitAtomicUpdate ( AllocaIP, X.Var , X.ElemTy , Expr, AO, AtomicOp, UpdateOp,
9203- X. IsVolatile , IsXBinopExpr );
9217+ Expected<std::pair<Value *, Value *>> AtomicResult = emitAtomicUpdate (
9218+ AllocaIP, X.Var , X.ElemTy , Expr, AO, AtomicOp, UpdateOp, X. IsVolatile ,
9219+ IsXBinopExpr, IsIgnoreDenormalMode, IsFineGrainedMemory, IsRemoteMemory );
92049220 if (!AtomicResult)
92059221 return AtomicResult.takeError ();
92069222 Value *CapturedVal =
0 commit comments