[clang] [Clang] Lower fp atomic compound stmts into atomicrmw (PR #216033)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 21 06:32:06 PDT 2026
================
@@ -4105,14 +4102,21 @@ LValue ScalarExprEmitter::EmitCompoundAssignLValue(
// the loaded integer to double, performing FP arithmetics, and truncation
// back as a single atomic operation. Integer promotion is still
// semantically safe.
- bool CanEmitAtomicRMW =
+ bool CanEmitIntegerRMW =
!AtomicValueTy->isBooleanType() && AtomicValueTy->isIntegerType() &&
ResultTy->isIntegerType() &&
!(AtomicValueTy->isUnsignedIntegerType() &&
CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow)) &&
CGF.getLangOpts().getSignedOverflowBehavior() !=
LangOptions::SOB_Trapping;
- if (CanEmitAtomicRMW) {
+ bool CanEmitFloatingRMW = false;
+ if (!Builder.getIsFPConstrained() && AtomicValueTy->isFloatingType() &&
----------------
Lukacma wrote:
I think I need to limit it based on rounding mode as well. As atomicrmw doesn't have constrained variant it is only valid with constrained operation, only if their rounding mode is "round.tonearest" as it needs to match default floating-point environment assumed by LLVM for non-constrained operations. But I agree that using getExceptionMode and getRoundingMode is more precise here !
https://github.com/llvm/llvm-project/pull/216033
More information about the cfe-commits
mailing list