http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50251
--- Comment #12 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-09-02 09:40:33 UTC --- (In reply to comment #3) > Created attachment 25162 [details] > optimized dump > > 1. The alloca in main is transformed into this declaration: > > <unnamed-unsigned:8> D.2129[24]; > > and accessed like this: > > iftmp.6_13 = MEM[symbol: D.2129, index: ivtmp.30_31, step: 4, > offset: 4294967292B]; > > MEM[symbol: D.2129, index: ivtmp.30_31, step: 4, offset: 0B] = D.2105_15; > > D.2099_18 = MEM[(int *)&D.2129][5]{lb: 0 sz: 4}; > > MEM[symbol: D.2129, index: ivtmp.30_31, step: 4, offset: 0B] = 0; > > > 2. __builtin_stack_restore/__builtin_stack_restore in main are not optimized > away, because the restored value is potentially used. The restored value is > the > same as the current value, so the restore is redundant, but that's not checked > in optimize_stack_restore. > > saved_stack.3_5 = __builtin_stack_save (); > > __builtin_stack_restore (saved_stack.3_5); It does try it here: second_stack_restore: /* If there's exactly one use, then zap the call to __builtin_stack_save. If there are multiple uses, then the last one should remove the call. In any case, whether the call to __builtin_stack_save can be removed or not is irrelevant to removing the call to __builtin_stack_restore. */ if (has_single_use (gimple_call_arg (call, 0))) but for some reason it doesn't trigger?