http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52445
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-01 09:01:59 UTC --- Not to mention that in this exact case, even if was always non-trapping, I doubt it will ever be an optimization to "optimize" if (len_1(D) > 1) goto <bb 5>; else goto <bb 6>; <bb 5>: MEM[(char *)buf_2(D) + 1B] = 0; <bb 6>: return; into: if (len_1(D) > 1) goto <bb 6>; else goto <bb 5>; <bb 5>: cstore.2_7 = MEM[(char *)buf_2(D) + 1B]; <bb 6>: # cstore.2_9 = PHI <cstore.2_7(5), 0(4)> MEM[(char *)buf_2(D) + 1B] = cstore.2_9; return; because the latter we then expand into: jbe .L8 movb %al, 1(%rdi) ret ... .L8: movzbl 1(%rdi), %eax movb %al, 1(%rdi) ret So if the conditional bb contains just the potentionally cselim optimized store, perhaps we should punt. Plus for C++11/C11 memory model we probably need to disable cselim optimization altogether.