https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64541
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization CC|rguenther at suse dot de |rguenth at gcc dot gnu.org Summary|.fre1 pass optimization |FRE pass optimization |failure |failure --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- The sources are different in that 2.c dereferences *p one more time after *q is stored to while 1.c dereferences *q for the return value. Thus an equivalent 2.c would be int f (int ** p, int ** q) { ++*p; *q = *p; return **q; } it is true that we can still optimize the original 2.c but only because *p and *q are equivalent (but it is probably not worthwhile the compile-time cost handling this). That is, we have to assume that p == q and thus the store to *q invalidates the previously load *p. I also think we have a duplicate report for this somewhere. Simpler testcase (which is probably that in the duplicate): int foo (int *p, int *q) { *p = 1; *q = 1; return *p; }