From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeffrey A Law To: john@feith.com (John Wehle) Cc: egcs@cygnus.com Subject: Re: Possible CSE quirk involving SUBREG on the i386 Date: Tue, 30 Jun 1998 04:50:00 -0000 Message-id: <15831.899190753@hurl.cygnus.com> References: <199806300534.BAA27602@jwlab.FEITH.COM> X-SW-Source: 1998-06/msg01111.html In message < 199806300534.BAA27602@jwlab.FEITH.COM >you write: > Compiling: > > unsigned short c; > > int > func(unsigned short a) > { > unsigned short b; > > b = a; > c = b; > > return b; > } > > for the i386 using egcs current with -O -S yields: > > _func: > pushl %ebp > movl %esp,%ebp > movl 8(%ebp),%eax > movl %eax,%edx > movw %ax,_c > movzwl %dx,%eax > leave > ret > > Which is interesting since I expected: > > _func: > pushl %ebp > movl %esp,%ebp > movl 8(%ebp),%eax > movw %ax,_c > movzwl %ax,%eax > leave > ret I'm not sure this is really a CSE issue. Though it might be a combine issue. ;; Start of basic block 0, registers live: 6 [bp] 16 [] (insn 4 2 6 (set (reg:SI 22) (mem:SI (reg:SI 16 %argp))) 54 {movsi+2} (nil) (expr_list:REG_EQUIV (mem:SI (reg:SI 16 %argp)) (nil))) (insn 6 4 7 (set (reg/v:HI 21) (subreg:HI (reg:SI 22) 0)) 58 {movhi+1} (insn_list 4 (nil)) (nil)) (note 7 6 8 "" NOTE_INSN_FUNCTION_BEG) (note 8 7 10 "" NOTE_INSN_DELETED) (note 10 8 16 0 NOTE_INSN_BLOCK_BEG) (insn 16 10 18 (set (mem:HI (symbol_ref:SI ("c"))) (subreg:HI (reg:SI 22) 0)) 58 {movhi+1} (nil) (expr_list:REG_DEAD (reg:SI 22) (nil))) (insn 18 16 20 (set (reg:SI 24) (zero_extend:SI (reg/v:HI 21))) 86 {zero_extendhisi2} (insn_list 6 (nil)) (expr_list:REG_DEAD (reg/v:HI 21) (nil))) If we were to combine insns 6 & 18 I think we'd get the code you want. I don't know why combine isn't doing this. jeff