From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20953 invoked by alias); 18 Mar 2011 13:26:44 -0000 Received: (qmail 20942 invoked by uid 22791); 18 Mar 2011 13:26:42 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mo-p00-ob.rzone.de (HELO mo-p00-ob.rzone.de) (81.169.146.160) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Mar 2011 13:26:37 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT2k715jHQaJercGObUOFkj18odoYNahU4Q== X-RZG-CLASS-ID: mo00 Received: from [192.168.0.22] (business-188-111-022-002.static.arcor-ip.net [188.111.22.2]) by post.strato.de (fruni mo58) (RZmta 25.8) with ESMTPA id p056abn2ICvjuN ; Fri, 18 Mar 2011 14:26:35 +0100 (MET) Message-ID: <4D835D8A.5000400@gjlay.de> Date: Fri, 18 Mar 2011 13:26:00 -0000 From: Georg-Johann Lay User-Agent: Thunderbird 2.0.0.24 (X11/20100302) MIME-Version: 1.0 To: "Paulo J. Matos" CC: gcc@gcc.gnu.org Subject: Re: avr compilation References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg00256.txt.bz2 Paulo J. Matos schrieb: > Hi all, > > I am looking at the avr backend in order to try to sort some things out > on my own backend. > > One of the tests I am doing is by compiling the following: > int x = 0x1010; > int y = 0x0101; > > int add(void) > { > return x+y; > } > > It compiles to (in gcc-4.3.5_avr with -Os) > add: > /* prologue: function */ > /* frame size = 0 */ > lds r18,y > lds r19,(y)+1 > lds r24,x > lds r25,(x)+1 > add r18,r24 > adc r19,r25 > mov r24,r18 > mov r25,r19 > /* epilogue start */ > ret > > I don't know much avr assembler so bear with me but I would expect this note that the last moves are two QI moves, the add is HI. Without splitting HI the moves will disappear, try -fno-split-wide-types. Johann > to be written: > add: > /* prologue: function */ > /* frame size = 0 */ > lds r18,y > lds r19,(y)+1 > lds r24,x > lds r25,(x)+1 > add r24,r18 > adc r25,r19 > /* epilogue start */ > ret > > By inverting the add arguments we save two mov instructions. > > If it can be written like this any ideas on why GCC is avoiding it? Try newer version of gcc, like 4.5.2 > > Cheers, > > -- > PMatos