From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24452 invoked by alias); 15 Jan 2003 00:15:23 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 24434 invoked from network); 15 Jan 2003 00:15:19 -0000 Received: from unknown (HELO linisoft.localdomain) (24.80.72.10) by 209.249.29.67 with SMTP; 15 Jan 2003 00:15:19 -0000 Received: from linisoft.com (IDENT:reza@linisoft.localdomain [127.0.0.1]) by linisoft.localdomain (8.9.3/8.8.7) with ESMTP id QAA13376; Tue, 14 Jan 2003 16:12:23 -0800 Message-ID: <3E24A767.F9CDAFB0@linisoft.com> Date: Wed, 15 Jan 2003 05:10:00 -0000 From: Reza Roboubi X-Accept-Language: en MIME-Version: 1.0 To: Andrew Pinski CC: gcc-help , "gcc@gcc.gnu.org" Subject: Re: optimizations References: <0E499A65-2803-11D7-9221-00039372607E@physics.uc.edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2003-01/txt/msg00709.txt.bz2 Andrew Pinski wrote: > > What version of gcc? > This seems like it was fixed at one point doing the 3.x series because > it does not happen with 3.3 (prerelease) or 3.4 (experimental). Ah. I am using gcc version 3.2. It's very good if this has been fixed under 3.3 and 3.4. I would still appreciate any comments regarding the status of these optimizations. Are these new features, or are they old ones that temporarily got broken during gcc 3.2? What part of the gcc source tree deals with these optimizations? Thanks again. > > Thanks, > Andrew Pinski > > On Tuesday, Jan 14, 2003, at 12:35 US/Pacific, Reza Roboubi wrote: > > > In the following code, it is clear that the return value of mm() can be > > eliminated. In fact, many optimizations are possible here. Yet gcc > > seems not > > to be able to do these optimizations. Below, I posted the assembly > > code that > > gcc generated (for the while() loop). > > > > I compiled this code with gcc -O2 -Wall. > > > > I was wondering if I am doing something wrong. If not, then please > > comment on > > current gcc developments in this regard, and what it takes to add some > > of these > > features. > > > > Please also comment on how other compilers would compare with gcc in > > this case. > > > > Are there any non-obvious remedies you have for this case? > > > > PS: Please tell me if I must report this as a gcc bug. > > > > Thanks in advance for any help you provide. > > > > > > inline int mm(int *i) > > { > > if((*i)==0x10){return 0;} > > (*i)++;return 1; > > } > > > > int > > main(){ > > > > int k=0; > > while (mm(&k)){} > > write(1,&k,1); > > > > return 0; > > } > > > > > > Associated assembly code for the while() loop: > > > > 0x80483b0 : mov 0xfffffffc(%ebp),%eax > > 0x80483b3 : xor %edx,%edx > > 0x80483b5 : cmp $0x10,%eax > > 0x80483b8 : je 0x80483c3 > > 0x80483ba : inc %eax > > 0x80483bb : mov $0x1,%edx > > 0x80483c0 : mov %eax,0xfffffffc(%ebp) > > 0x80483c3 : test %edx,%edx > > 0x80483c5 : jne 0x80483b0 > > -- Reza Roboubi IT Solution Provider: Software Development; Data Servers; Embedded Devices. www.linisoft.com