https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69368
--- Comment #66 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Dominique d'Humieres from comment #65) > > There is obviously no "rationale". Fact is that we don't exploit the > > undefinedness explicitely but just as a side-effect of how CSE works in > > DOM now. This means we don't propagate '1' as the only valid value of I > > but just CSE the last three loads to the first as we know they are the > > same (without knowing the actual value). > > How can K(1) and K(2*1) be the same without using undefinedness explicitely? They can't, but why does that matter for undefined behavior? The CSE code in DOM doesn't try to analyze the array indices at all, it is enough for it to prove that in valid program they must be all same. Whether the compiler could with additional efforts prove they are different or not (it can't e.g. without LTO and without seeing caller that passes two different variables).