GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fold-const Performance Win

fold-const: take wide_int arguments by const reference

Pass wide_int arguments by const reference to avoid unnecessary copies.

The functions minmax_from_comparison and fold_cmp_float_cst_p in fold-const.cc previously took large wide_int arguments by value. These arguments are only read, so they are now passed by const reference. This change avoids copying 80-byte wide_int values on x86_64, improving efficiency without altering program behavior.

In Details

The functions minmax_from_comparison and fold_cmp_float_cst_p operate on wide_int types, which can be large (e.g., 80 bytes on x86_64). Passing these by value incurs significant copy overhead. This commit changes the parameter passing mechanism to const reference for these arguments to eliminate redundant copies, as the arguments are not modified.

For Context
wide_int
An arbitrary-precision integer type used in GCC for representing values that exceed the standard machine integer types. It is crucial for intermediate calculations in various optimization passes.
const reference
A way to pass arguments to functions in C++ that allows the function to access the argument's value without making a copy, while also guaranteeing that the function will not modify the original argument.
Filed Under: optimizationperformance