@@ -8960,7 +8960,9 @@ OpenMPIRBuilder::createAtomicWrite(const LocationDescription &Loc,
89608960OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createAtomicUpdate (
89618961 const LocationDescription &Loc, InsertPointTy AllocaIP, AtomicOpValue &X,
89628962 Value *Expr, AtomicOrdering AO, AtomicRMWInst::BinOp RMWOp,
8963- AtomicUpdateCallbackTy &UpdateOp, bool IsXBinopExpr) {
8963+ AtomicUpdateCallbackTy &UpdateOp, bool IsXBinopExpr,
8964+ bool IsAmdgpuIgnoreDenormalMode, bool IsNoFineGrainedMemory,
8965+ bool IsNoRemoteMemory) {
89648966 assert (!isConflictIP (Loc.IP , AllocaIP) && " IPs must not be ambiguous" );
89658967 if (!updateToLocation (Loc))
89668968 return Loc.IP ;
@@ -8980,7 +8982,8 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createAtomicUpdate(
89808982
89818983 Expected<std::pair<Value *, Value *>> AtomicResult =
89828984 emitAtomicUpdate (AllocaIP, X.Var , X.ElemTy , Expr, AO, RMWOp, UpdateOp,
8983- X.IsVolatile , IsXBinopExpr);
8985+ X.IsVolatile , IsXBinopExpr, IsAmdgpuIgnoreDenormalMode,
8986+ IsNoFineGrainedMemory, IsNoRemoteMemory);
89848987 if (!AtomicResult)
89858988 return AtomicResult.takeError ();
89868989 checkAndEmitFlushAfterAtomic (Loc, AO, AtomicKind::Update);
@@ -9027,7 +9030,9 @@ Value *OpenMPIRBuilder::emitRMWOpAsInstruction(Value *Src1, Value *Src2,
90279030Expected<std::pair<Value *, Value *>> OpenMPIRBuilder::emitAtomicUpdate (
90289031 InsertPointTy AllocaIP, Value *X, Type *XElemTy, Value *Expr,
90299032 AtomicOrdering AO, AtomicRMWInst::BinOp RMWOp,
9030- AtomicUpdateCallbackTy &UpdateOp, bool VolatileX, bool IsXBinopExpr) {
9033+ AtomicUpdateCallbackTy &UpdateOp, bool VolatileX, bool IsXBinopExpr,
9034+ bool IsAmdgpuIgnoreDenormalMode, bool IsAmdgpuNoFineGrainedMemory,
9035+ bool IsAmdgpuNoRemoteMemory) {
90319036 // TODO: handle the case where XElemTy is not byte-sized or not a power of 2
90329037 // or a complex datatype.
90339038 bool emitRMWOp = false ;
@@ -9050,7 +9055,18 @@ Expected<std::pair<Value *, Value *>> OpenMPIRBuilder::emitAtomicUpdate(
90509055
90519056 std::pair<Value *, Value *> Res;
90529057 if (emitRMWOp) {
9053- Res.first = Builder.CreateAtomicRMW (RMWOp, X, Expr, llvm::MaybeAlign (), AO);
9058+ AtomicRMWInst *atomicRMWInst =
9059+ Builder.CreateAtomicRMW (RMWOp, X, Expr, llvm::MaybeAlign (), AO);
9060+ if (IsAmdgpuIgnoreDenormalMode)
9061+ atomicRMWInst->setMetadata (" amdgpu.ignore.denormal.mode" ,
9062+ llvm::MDNode::get (Builder.getContext (), {}));
9063+ if (IsAmdgpuNoFineGrainedMemory)
9064+ atomicRMWInst->setMetadata (" amdgpu.no.fine.grained.memory" ,
9065+ llvm::MDNode::get (Builder.getContext (), {}));
9066+ if (IsAmdgpuNoRemoteMemory)
9067+ atomicRMWInst->setMetadata (" amdgpu.no.remote.memory" ,
9068+ llvm::MDNode::get (Builder.getContext (), {}));
9069+ Res.first = atomicRMWInst;
90549070 // not needed except in case of postfix captures. Generate anyway for
90559071 // consistency with the else part. Will be removed with any DCE pass.
90569072 // AtomicRMWInst::Xchg does not have a coressponding instruction.
@@ -9182,7 +9198,9 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createAtomicCapture(
91829198 const LocationDescription &Loc, InsertPointTy AllocaIP, AtomicOpValue &X,
91839199 AtomicOpValue &V, Value *Expr, AtomicOrdering AO,
91849200 AtomicRMWInst::BinOp RMWOp, AtomicUpdateCallbackTy &UpdateOp,
9185- bool UpdateExpr, bool IsPostfixUpdate, bool IsXBinopExpr) {
9201+ bool UpdateExpr, bool IsPostfixUpdate, bool IsXBinopExpr,
9202+ bool IsAmdgpuIgnoreDenormalMode, bool IsAmdgpuNoFineGrainedMemory,
9203+ bool IsAmdgpuNoRemoteMemory) {
91869204 if (!updateToLocation (Loc))
91879205 return Loc.IP ;
91889206
@@ -9203,7 +9221,8 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createAtomicCapture(
92039221 AtomicRMWInst::BinOp AtomicOp = (UpdateExpr ? RMWOp : AtomicRMWInst::Xchg);
92049222 Expected<std::pair<Value *, Value *>> AtomicResult =
92059223 emitAtomicUpdate (AllocaIP, X.Var , X.ElemTy , Expr, AO, AtomicOp, UpdateOp,
9206- X.IsVolatile , IsXBinopExpr);
9224+ X.IsVolatile , IsXBinopExpr, IsAmdgpuIgnoreDenormalMode,
9225+ IsAmdgpuNoFineGrainedMemory, IsAmdgpuNoRemoteMemory);
92079226 if (!AtomicResult)
92089227 return AtomicResult.takeError ();
92099228 Value *CapturedVal =
0 commit comments