[clang] [Clang] Fix clang to emit llvm-ir for fadd/fsub atomics (PR #162679)

Amina Chabane via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 22 05:51:39 PDT 2025


================
@@ -3854,7 +3847,16 @@ LValue ScalarExprEmitter::EmitCompoundAssignLValue(
   llvm::PHINode *atomicPHI = nullptr;
   if (const AtomicType *atomicTy = LHSTy->getAs<AtomicType>()) {
     QualType type = atomicTy->getValueType();
-    if (!type->isBooleanType() && type->isIntegerType() &&
+    const bool isFloat = type->isFloatingType();
+    const bool isInteger = type->isIntegerType();
+
+    bool isPowerOfTwo = false;
+    if (isFloat || isInteger) {
+      llvm::Type *IRTy = CGF.ConvertType(type);
+      uint64_t StoreBits = CGF.CGM.getDataLayout().getTypeStoreSizeInBits(IRTy);
+      isPowerOfTwo = llvm::isPowerOf2_64(StoreBits);
+    }
+    if (!type->isBooleanType() && (isInteger || isFloat) && isPowerOfTwo &&
----------------
Amichaxx wrote:

Done, thanks.

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


More information about the cfe-commits mailing list