GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc

Downgrade [[assume]] intrinsic from const to pure

Marks the [[assume]] intrinsic as 'pure' instead of 'const' for more accurate analysis.

The internal function __builtin_assume (marked with IFN_ASSUME) was incorrectly marked as const, implying it had no side effects and did not read global memory. This commit changes its attribute to pure, which allows reading global memory. This corrects analysis inaccuracies, especially when the assume body references fields of structures, even though the body itself is not executed.

In Details

The IFN_ASSUME intrinsic, representing [[assume(...)]], was incorrectly classified as const. While the intrinsic call itself doesn't read memory, it dispatches to an outlined assume body which *could* read memory. Changing its attribute from const to pure reflects this accurately, preventing misinterpretation by optimization passes that rely on function attributes.

For Context
const attribute
A function attribute indicating that the function does not modify any global state and does not read global memory. It must be side-effect free.
pure attribute
A function attribute indicating that the function does not modify any global state but may read global memory. It must be side-effect free with respect to global state.
intrinsic
A function or operation that is recognized and handled directly by the compiler, often mapping to specific machine instructions or providing optimized built-in functionality.
Filed Under: optimizationanalysis