https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96482
--- Comment #5 from Yevhenii Kolesnikov <yevh.kolesnikov at gmail dot com> --- (In reply to Martin Liška from comment #3) > Thank you for the report, I can take a look. > Can you please provide steps how to build Mesa with -O3 and -flto? mesa is configured with meson. LTO can be enabled with builtin option -b_lto=true. Options can be supplied to the compiler with -Dc_args and -Dcpp_args. So, to enable O3 it's -Dc_args="-O3" -Dcpp_args="-O3". You'll also need to set -Dbuildtype=plain, or otherwise these options will be overwritten. So, the full build process will look like this: meson \ -Dbuildtype=plain \ -Dvalgrind=false \ -Ddri-drivers=i965 \ -Dgallium-drivers=iris,swrast \ -Dvulkan-drivers= \ -Dgallium-omx="disabled" \ -Dplatforms=x11,drm,surfaceless \ -Dllvm=false \ -Db_lto=true \ -Dc_args="-g \ -O3 \ " \ -Dcpp_args="-g \ -O3 \ " \ --prefix=~/builds/mesa-bug \ ./mesa-bug ninja -C ./mesa-bug install The aforementioned functions and assembly code then will be in ~/builds/mesa-bug/lib/dri/iris_dri.so > About the addr_to_index function: am I right that unreachable is defined in > your configuration as __builtin_unreachable? To be precise, unreachable is defined like this: #define unreachable(str) \ do { \ assert(!str); \ __builtin_unreachable(); \ } while (0) I'm not sure why this one-time loop is necessary, to be honest. > Can you please replace it with fprintf that prints the value? The value of addr_format? It doesn't print anything, since this branch is never hit. Moreover, it prevents addr_to_index from being inlined, so the crash goes away. The value of addr_format in my case is 3, which corresponds to the nir_address_format_32bit_index_offset enum. So, in my case, the first branch is always hit.