From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22109 invoked by alias); 25 Jul 2002 11:29:33 -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 22097 invoked from network); 25 Jul 2002 11:29:31 -0000 Received: from unknown (HELO sohm.kpit.com) (203.129.230.82) by sources.redhat.com with SMTP; 25 Jul 2002 11:29:31 -0000 X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: FW: H8300 optimization Date: Thu, 25 Jul 2002 10:18:00 -0000 Message-ID: <69595093233BB547BB70CF5E492B63F2531601@sohm.kpit.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: From: "Dhananjay R. Deshpande" To: X-SW-Source: 2002-07/txt/msg01210.txt.bz2 -----Original Message----- From: Dhananjay R. Deshpande=20 Sent: Thursday, July 25, 2002 4:47 PM To: 'gcc-bugs@gcc.gnu.org' Subject: H8300 optimization Hi, I have a simple function which returns max of two unsigned integers. unsigned int maxu(unsigned int a, unsigned int b) { return ( a > b ? a : b ); } Compiling it with h8300-hms-gcc -S -O2 -fomit-frame-pointer gives - =20 .section .text .align 1 .global _maxu _maxu: mov.w r0,r2 mov.w r1,r0 cmp.w r2,r1 bhs .L2 mov.w r2,r0 .L2: rts .end .ident "GCC: (GNU) 3.1" Here use of r2 as scratch register is not required. One could write=20 cmp.w r1,r0=20=20=20=20 bhs .L2 mov.w r1,r0=20 .L2:=20 This could save 2 instructions. Is it possible to generate this sequence from compiler?=20 I tried to understand from RTL dump how r2 comes into picture. It looks like global reg alloc allocates r0 for b and r2 for a and this is causing=20 use of extra register and 2 extra instructions. Regards, Dhananjay