From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeffrey A Law To: john@feith.com (John Wehle) Cc: egcs@egcs.cygnus.com Subject: Re: Possible CSE quirk involving SUBREG on the i386 Date: Tue, 09 Mar 1999 01:09:00 -0000 Message-id: <24868.920970568@hurl.cygnus.com> In-reply-to: Your message of Tue, 30 Jun 1998 01:34:22 MDT. <199806300534.BAA27602@jwlab.FEITH.COM> References: <199806300534.BAA27602@jwlab.FEITH.COM> X-SW-Source: 1999-03/msg00341.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 > > The use of %edx seems wasteful. Yes. Wasteful. Compiling this with the current sources yields: func: pushl %ebp # 32 movsi-2 movl %esp,%ebp # 34 movsi+2/1 movzwl 8(%ebp),%eax # 4 zero_extendhisi2+2/2 movw %ax,c # 16 movhi+1/1 leave # 37 leave ret # 38 return_internal Which is even better than what you expected ;-) jeff From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeffrey A Law To: john@feith.com (John Wehle) Cc: egcs@egcs.cygnus.com Subject: Re: Possible CSE quirk involving SUBREG on the i386 Date: Wed, 31 Mar 1999 23:46:00 -0000 Message-ID: <24868.920970568@hurl.cygnus.com> References: <199806300534.BAA27602@jwlab.FEITH.COM> X-SW-Source: 1999-03n/msg00343.html Message-ID: <19990331234600.GzjIZ-LTSlbMldIxHs1rHSblWDkrIDgseyOtIOZUo38@z> 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 > > The use of %edx seems wasteful. Yes. Wasteful. Compiling this with the current sources yields: func: pushl %ebp # 32 movsi-2 movl %esp,%ebp # 34 movsi+2/1 movzwl 8(%ebp),%eax # 4 zero_extendhisi2+2/2 movw %ax,c # 16 movhi+1/1 leave # 37 leave ret # 38 return_internal Which is even better than what you expected ;-) jeff