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

Ada optimization: Cannot_Be_Superflat flag set in special if_expression expansion.

Ada compiler sets Cannot_Be_Superflat flag in special if_expression expansion to optimize unconstrained array results.

This Ada compiler change optimizes the special expansion of if_expression by setting the Cannot_Be_Superflat flag. This applies to cases where a unidimensional unconstrained array has a result type, and its dependent expressions have constrained subtypes with known bounds. This special expansion avoids dynamic stack allocation and by setting the flag, further aids in optimizing subsequent processing of these types.

In Details

In the Ada front-end's exp_ch4.adb, the Expand_N_If_Expression procedure handles a specific expansion for if_expression. This commit modifies that special case: when the result is a unidimensional unconstrained array and the two dependent expressions involve constrained subtypes with known bounds, the Cannot_Be_Superflat flag is now set. This flag likely informs later stages about the nature of the resulting array type, aiding in optimization by avoiding dynamic stack allocation and potentially simplifying range-related operations.

For Context
if_expression
A construct in Ada that allows conditional evaluation, similar to a ternary operator in other languages.
unconstrained array
An array type whose index ranges are not specified at the time of type definition; their bounds are determined by the specific object's declaration.
constrained subtype
A subtype that has explicit bounds or constraints on its values, unlike an unconstrained type.
Cannot_Be_Superflat
A flag likely indicating that a particular discrete range or array type does not conform to a simplified 'superflat' structure, potentially requiring more complex handling or indicating optimization opportunities.
Filed Under: adaoptimizationcode generation