This code: extern char *nl_langinfo (int) __attribute__ ((__nothrow__)); char * xtermEnvEncoding(void) { static char *result;
if (result == 0) result = nl_langinfo(50); return result; } gets compile by gcc-4.1.0 -march=i686 -mtune=i686 to: xtermEnvEncoding: [snip] .L6: movl $50, (%esp) call nl_langinfo movl %eax, result.1281 movl result.1281, %eax <---- note this leave ret Note the redundant mov instruction. 4.0 does not generate that extra instruction. The extra instruction seems to be generated by the bbro pass. Here is the RTL dump for the .44.rnreg pass: nothing unusual (call_insn:HI 17 16 19 1 (set (reg:SI 0 ax) (call (mem:QI (symbol_ref:SI ("nl_langinfo") [flags 0x41] <function_decl 0xb7f2f100 nl_langinfo>) [0 S1 A8]) (const_int 4 [0x4]))) 531 {*call_value_0} (nil) (expr_list:REG_EH_REGION (const_int 0 [0x0]) (nil)) (nil)) (insn:HI 19 17 20 1 (set (mem/f/c/i:SI (symbol_ref:SI ("result.1281") [flags 0x2] <var_decl 0xb7ebb108 result>) [2 result+0 S4 A32]) (reg:SI 0 ax [orig:58 D.1283 ] [58])) 34 {*movsi_1} (insn_list:REG_DEP_TRUE 18 (nil )) (expr_list:REG_DEAD (reg:SI 0 ax [orig:58 D.1283 ] [58]) (nil))) but the next dump, .45.bbro shows that an extra move instruction has been inserted. (call_insn:HI 17 16 19 2 (set (reg:SI 0 ax) (call (mem:QI (symbol_ref:SI ("nl_langinfo") [flags 0x41] <function_decl 0xb7f2f100 nl_langinfo>) [0 S1 A8]) (const_int 4 [0x4]))) 531 {*call_value_0} (nil) (expr_list:REG_EH_REGION (const_int 0 [0x0]) (nil)) (nil)) (insn:HI 19 17 54 2 (set (mem/f/c/i:SI (symbol_ref:SI ("result.1281") [flags 0x2] <var_decl 0xb7ebb108 result>) [2 result+0 S4 A32]) (reg:SI 0 ax [orig:58 D.1283 ] [58])) 34 {*movsi_1} (insn_list:REG_DEP_TRUE 18 (nil )) (expr_list:REG_DEAD (reg:SI 0 ax [orig:58 D.1283 ] [58]) (nil))) (insn 54 19 55 2 (set (reg/f:SI 0 ax [orig:61 result ] [61]) (mem/f/c/i:SI (symbol_ref:SI ("result.1281") [flags 0x2] <var_decl 0xb7ebb108 resul t>) [2 result+0 S4 A32])) 34 {*movsi_1} (nil) (nil)) This problem is one of the causes for PR23153. -- Summary: Basic block reordering inserts redundant instruction Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dann at godzilla dot ics dot uci dot edu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26537