From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18577 invoked by alias); 18 Mar 2011 08:48:00 -0000 Received: (qmail 18567 invoked by uid 22791); 18 Mar 2011 08:48:00 -0000 X-SWARE-Spam-Status: No, hits=0.3 required=5.0 tests=AWL,BAYES_00,DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_NUMERIC_HELO,SPF_HELO_PASS,T_RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from lo.gmane.org (HELO lo.gmane.org) (80.91.229.12) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Mar 2011 08:47:56 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q0VLc-0006GW-3J for gcc@gcc.gnu.org; Fri, 18 Mar 2011 09:47:52 +0100 Received: from 193.128.72.68 ([193.128.72.68]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 18 Mar 2011 09:47:52 +0100 Received: from pocmatos by 193.128.72.68 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 18 Mar 2011 09:47:52 +0100 To: gcc@gcc.gnu.org From: "Paulo J. Matos" Subject: avr compilation Date: Fri, 18 Mar 2011 08:48:00 -0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 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/msg00251.txt.bz2 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