https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89922
--- Comment #4 from Antony Polukhin <antoshkka at gmail dot com> --- > Was the testcase just an artificial one or does it appear (in this > isolated form!) in a real application/benchmark? I was not investigating a particular benchmark or real world application at first. My guess is that heuristic will affect cryptography (initializing big arrays with magic constants) and math (matrix multiplication with identity matrix for example). I've tried to check the validity of the guess. The very first attempt succeeded. Hash computation for a constant string is not well optimized: https://godbolt.org/z/iKi0pb The heuristic may notice that the string is a local variable and may force the loop unrolling. Hash computations on a constant variable is a common case in libstdc++ when working with unordered maps and sets. There's definitely some room for improvement for cases when a local variable is used in the loop only.