From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 983 invoked by alias); 8 Jan 2005 05:59:46 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 940 invoked from network); 8 Jan 2005 05:59:38 -0000 Received: from unknown (HELO eastnet.febras.ru) (212.91.197.11) by sourceware.org with SMTP; 8 Jan 2005 05:59:38 -0000 Received: from marine.febras.ru ([212.91.197.10]) by eastnet.febras.ru with esmtp (Exim 4.43) id 1Cn9dW-0006nn-P9 for gcc-help@gcc.gnu.org; Sat, 08 Jan 2005 15:59:42 +1000 Received: from [192.168.11.218] (helo=192.168.11.218) by marine.febras.ru with esmtp (Exim 4.12) id 1Cn9dS-0001pY-00 for gcc-help@gcc.gnu.org; Sat, 08 Jan 2005 15:59:38 +1000 From: "Dmitry K." To: gcc-help@gcc.gnu.org Subject: How to force GNU CC use "inc" for `++' operator? Date: Sat, 08 Jan 2005 05:59:00 -0000 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200501081601.12229.dmixm@marine.febras.ru> X-SW-Source: 2005-01/txt/msg00039.txt.bz2 Hi. In the next example GCC differently processes two alike lines, containing increment of `c': extern int foo1 (int,int); int foo (int x, int y) { unsigned char c= 0; if (foo1(x,y)) c++; if (foo1(x,y)) c++; return c; } `inc r15' is used at the second increment. But at first -- pair operations: `ldi' and `mov'. This occupies two words instead of one and is executed twice longer: foo: /* prologue: frame size=0 */ push r15 push r16 push r17 push r28 push r29 /* prologue end (size=5) */ movw r16,r24 movw r28,r22 clr r15 rcall foo1 or r24,r25 breq .L2 ldi r24,lo8(1) /**************/ mov r15,r24 /**************/ .L2: movw r22,r28 movw r24,r16 rcall foo1 or r24,r25 breq .L3 inc r15 /**************/ .L3: mov r24,r15 clr r25 /* epilogue: frame size=0 */ pop r29 pop r28 pop r17 pop r16 pop r15 ret Certainly, 4% is rubbish. But this example is an extract from real program, where lack of the free register gave considerable decline. Was used: gcc 3.4.3, --target=avr, -Os, -mmcu=atmega8 Thanks in advance.