https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66348
--- Comment #6 from Sebastiano Vigna <sebastiano.vigna at unimi dot it> --- I forgot an important aspect: with -fsanitize=undefined the optimization bug does not show up. The instrumentation perturbs the code enough to make it go away.