------- Additional Comments From ebotcazou at gcc dot gnu dot org 2005-01-06 22:24 ------- > The RTL is wrong right away: > (insn 13 11 14 (set (reg:HI 60) > (subreg/u:HI (reg/v:SI 58 [ ad ]) 0)) -1 (nil) > (nil)) > > (insn 14 13 15 (parallel [ > (set (reg:SI 61) > (plus:SI (subreg:SI (reg:HI 60) 0) > (const_int -16384 [0xffffc000]))) > (clobber (reg:CC 17 flags)) > ]) -1 (nil) > (nil)) > > (insn 15 14 16 (set (reg:CCGOC 17 flags) > (compare:CCGOC (subreg:HI (reg:SI 61) 0) > (const_int 0 [0x0]))) -1 (nil) > (nil)) > > (jump_insn 16 15 0 (set (pc) > (if_then_else (lt (reg:CCGOC 17 flags) > (const_int 0 [0x0])) > (label_ref 0) > (pc))) -1 (nil) > (expr_list:REG_BR_PROB (const_int 9900 [0x26ac]) > (nil)))
I don't think the initial RTL is wrong: note that, while we perform the addition in SImode, we still compare in HImode. The problem appears to come from the combiner, which gets rid of the HImode in the comparison. > on PPC we get: > (insn 11 9 12 (set (reg:HI 119) > (subreg/u:HI (reg/v:SI 118 [ ad ]) 2)) -1 (nil) > (nil)) > > (insn 12 11 13 (set (reg:SI 120) > (plus:SI (subreg:SI (reg:HI 119) 0) > (const_int -16384 [0xffffffffffffc000]))) -1 (nil) > (nil)) > > (insn 13 12 14 (set (reg:SI 121) > (sign_extend:SI (subreg:HI (reg:SI 120) 2))) -1 (nil) > (nil)) > > (insn 14 13 15 (set (reg:CC 122) > (compare:CC (reg:SI 121) > (const_int 0 [0x0]))) -1 (nil) > (nil)) > > (jump_insn 15 14 0 (set (pc) > (if_then_else (lt (reg:CC 122) > (const_int 0 [0x0])) > (label_ref 0) > (pc))) -1 (nil) > (expr_list:REG_BR_PROB (const_int 9900 [0x26ac]) > (nil))) > > > Notice the sign_extend in the PPC but not in the x86 case. This RTL is indeed more elegant and probably less error-prone. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19296