From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6511 invoked by alias); 18 Mar 2011 10:08:18 -0000 Received: (qmail 6501 invoked by uid 22791); 18 Mar 2011 10:08:17 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-iy0-f175.google.com (HELO mail-iy0-f175.google.com) (209.85.210.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Mar 2011 10:08:12 +0000 Received: by iyb26 with SMTP id 26so4090041iyb.20 for ; Fri, 18 Mar 2011 03:08:10 -0700 (PDT) Received: by 10.43.63.203 with SMTP id xf11mr1185621icb.316.1300442890619; Fri, 18 Mar 2011 03:08:10 -0700 (PDT) Received: from localhost.localdomain ([202.149.225.194]) by mx.google.com with ESMTPS id 41sm1335474ibi.44.2011.03.18.03.08.07 (version=SSLv3 cipher=OTHER); Fri, 18 Mar 2011 03:08:09 -0700 (PDT) Message-ID: <4D832F02.6080508@gmail.com> Date: Fri, 18 Mar 2011 10:08:00 -0000 From: "WANG.Jiong" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9 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; format=flowed 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/msg00252.txt.bz2 This may related with subreg regmove finding Suggest specifiy -fdump-rtl-regmove to see what happen after this pass Maybe avr need a target dependent regmove pass to handle this Best, Jiong On 03/18/2011 04:47 PM, Paulo J. Matos wrote: > 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 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? > > Cheers, > > -- > PMatos >