GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc

Xtensa provides TARGET_ATOMIC_ASSIGN_EXPAND_FENV for atomic operations

Xtensa now supports atomic floating-point operations by providing TARGET_ATOMIC_ASSIGN_EXPAND_FENV, fixing fenv results in tests.

This commit introduces TARGET_ATOMIC_ASSIGN_EXPAND_FENV for the Xtensa architecture, enabling correct handling of floating-point environment (fenv) results for atomic operations. This fix addresses an issue where atomic operations on FP values did not properly update the floating-point status flags. By implementing the necessary built-in functions and patterns, GCC can now correctly expand atomic assignments involving floating-point types on Xtensa, ensuring accurate fenv behavior as verified by the c11-atomic-exec-5.c test.

In Details

For the Xtensa architecture, this commit introduces TARGET_ATOMIC_ASSIGN_EXPAND_FENV by defining xtensa_atomic_assign_expand_fenv. This ensures that atomic assignments involving floating-point values correctly update the floating-point exception status. It involves declaring and defining intrinsics for getting (__builtin_xtensa_get_fsr) and setting (__builtin_xtensa_set_fsr) the FSR (Floating-Point Status Register), and implementing their expansion to the corresponding Xtensa instructions (get_fsr, set_fsr). This functionality is crucial for correctly handling floating-point excep…

For Context
fenv
Floating-Point Environment. Refers to the set of status flags and control settings that manage floating-point operations, including rounding modes and exception status (e.g., overflow, underflow, invalid operation).
atomic operations
Operations that are guaranteed to be executed indivisibly, without interruption from other threads or processes. This ensures data integrity in concurrent environments.
TARGET_ATOMIC_ASSIGN_EXPAND_FENV
A GCC target-specific macro that defines how atomic assignments involving floating-point types should be expanded, particularly concerning the handling of the floating-point environment (fenv).
Xtensa
A configurable processor architecture, often used in embedded systems, that allows designers to customize the instruction set.
FSR
Floating-Point Status Register. A register within the processor that holds flags indicating the status of floating-point operations, such as exceptions that have occurred.
Filed Under: xtensaatomicfloatfenv