This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Possible CSE quirk involving SUBREG on the i386
- To: john at feith dot com (John Wehle)
- Subject: Re: Possible CSE quirk involving SUBREG on the i386
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Tue, 30 Jun 1998 01:12:33 -0600
- cc: egcs at cygnus dot com
- Reply-To: law at cygnus dot com
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