I can only reproduce this problem on the sh target with a gcc version 3.4.3. However my analysis makes me believe the problem still exists on the trunk.
After greg I have the following sequence : (insn:HI 11 10 12 0 (set (reg/v/f:SI 2 r2 [orig:160 PrivateData_p ] [160]) (const_int 128 [0x80])) 122 {movsi_i} (nil) (nil)) (insn:HI 12 11 134 0 (set (reg/v/f:SI 2 r2 [orig:160 PrivateData_p ] [160]) (plus:SI (reg/v/f:SI 2 r2 [orig:160 PrivateData_p ] [160]) (reg:SI 3 r3 [orig:162 Device_p ] [162]))) 23 {*addsi3_compact} (insn_list 10 (insn_list 11 (nil))) (expr_list:REG_EQUAL (plus:SI (reg:SI 3 r3 [orig:162 Device_p ] [162]) (const_int 128 [0x80])) (nil))) ... (insn:HI 16 135 17 0 (set (reg:SI 1 r1 [166]) (const_int 188 [0xbc])) 122 {movsi_i} (nil) (nil)) (insn:HI 17 16 18 0 (set (reg:SI 1 r1 [166]) (plus:SI (reg:SI 1 r1 [166]) (reg/v/f:SI 2 r2 [orig:160 PrivateData_p ] [160]))) 23 {*addsi3_compact} (insn_list 16 (nil)) (expr_list:REG_EQUAL (plus:SI (reg:SI 3 r3 [orig:162 Device_p ] [162]) (const_int 316 [0x13c])) (nil))) 'reload_combine' decides to optimize insns 16/17. After the optimisation, there is a 'continue' and reload_combines tries other pattern. The problem is that with this 'continue' reg_state[regno] was is updated with the other uses (here r2). later on insn 11/12 are optimized away, believing that r2 is dead because not makrked in the reg_state use list, leaving it undefined. The problem is very difficult to isolate (didn't succeed on trunk with i686) but by reading the postreload code the bug seems latent. -- Summary: sh postreload bug (might be generic in trunk) Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: christian dot bruel at st dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnugcc GCC target triplet: sh-superh-elf-gcc http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30807