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

forwprop: Optimize enum types to unsigned char

Reduces memory usage in the forward propagation pass by using unsigned char for enums.

This commit optimizes the storage for two enumerations, long_mul_kind and long_mul_extract, within the tree-ssa-forwprop.cc file. By changing their underlying type from the default int to unsigned char, the compiler can potentially save space, as these enums are used in contexts where their values are small. This change is considered obvious and has been verified by bootstrapping and testing.

In Details

In tree-ssa-forwprop.cc, the long_mul_kind and long_mul_extract enums are used to represent states and classifications related to scalar multiplication within the forward propagation pass. Previously, these enums likely defaulted to int. This change explicitly sets their underlying type to unsigned char, which is a smaller data type. This optimization is safe because the observed usage of these enums indicates their values will always fit within an unsigned char, thus reducing memory footprint for data structures that contain them.

For Context
forwprop
Abbreviation for forward propagation, an optimization pass in compilers that replaces variables with their known values to simplify subsequent computations.
tree-ssa-forwprop.cc
A source file in GCC that implements the forward propagation optimization pass using the Static Single Assignment (SSA) form of the intermediate representation.
enum
An enumeration, a data type consisting of a set of named integer constants. In C++, enums can have different underlying types.
unsigned char
An integer data type that is typically 8 bits wide and can represent values from 0 to 255. It is smaller than a standard 'int'.
Filed Under: optimizationgccmemory usage