http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47575
Summary: store-motion removes global stores from endless loops Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: rgue...@gcc.gnu.org void foo (int *k) { for (;;) *k = 0; } is optimized to foo (int * k) { int k__lsm.2; <bb 2>: k__lsm.2_4 = MEM[(int *)k_1(D)]; <bb 3>: k__lsm.2_6 = 0; <bb 4>: goto <bb 3>; } by LIM, removing the global store. We can use is_hidden_global_store or friends and require at least one exit if that is true for a sm ref.