[clang] [Clang] Add support for fp when using min_fetch/max_fetch atomics (PR #160330)

Amina Chabane via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 29 08:52:55 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
----------------
Amichaxx wrote:

Hi, thank you for another review. I've since amended this.

https://github.com/llvm/llvm-project/pull/160330


More information about the cfe-commits mailing list