[clang] [Clang] Add support for fp when using min_fetch/max_fetch atomics (PR #160330)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 26 08:22:39 PDT 2025
================
@@ -507,20 +507,35 @@ static llvm::Value *EmitPostAtomicMinMax(CGBuilderTy &Builder,
bool IsSigned,
llvm::Value *OldVal,
llvm::Value *RHS) {
+ llvm::Type *ValTy = OldVal->getType();
+
llvm::CmpInst::Predicate Pred;
+ bool IsFP = ValTy->isFloatingPointTy();
+
switch (Op) {
default:
llvm_unreachable("Unexpected min/max operation");
+
case AtomicExpr::AO__atomic_max_fetch:
case AtomicExpr::AO__scoped_atomic_max_fetch:
- Pred = IsSigned ? llvm::CmpInst::ICMP_SGT : llvm::CmpInst::ICMP_UGT;
+ Pred = IsFP
+ ? llvm::CmpInst::FCMP_OGT
----------------
CarolineConcatto wrote:
Ok, I saw now that using llvm.maximum and llvm.minimum we can still lower to atomic instructions. I did know that before.
https://github.com/llvm/llvm-project/pull/160330
More information about the cfe-commits
mailing list