From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29186 invoked by alias); 29 Jul 2009 11:41:37 -0000 Received: (qmail 29174 invoked by uid 22791); 29 Jul 2009 11:41:36 -0000 X-SWARE-Spam-Status: No, hits=1.0 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_21,J_CHICKENPOX_31,J_CHICKENPOX_41,J_CHICKENPOX_51,SARE_SUB_ENC_UTF8,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mailout1.go2.pl (HELO mailout1.go2.pl) (193.17.41.11) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 29 Jul 2009 11:41:30 +0000 Received: from mailout1.go2.pl (unknown [10.0.0.103]) by mailout1.go2.pl (Postfix) with ESMTP id 12F3B5D5143 for ; Wed, 29 Jul 2009 13:41:24 +0200 (CEST) Received: from o2.pl (unknown [10.0.0.140]) by mailout1.go2.pl (Postfix) with SMTP for ; Wed, 29 Jul 2009 13:41:24 +0200 (CEST) Subject: =?UTF-8?Q?m68k_-_GCC_4.4.0_generates_not_so_good_code_from_asm_inline?= From: =?UTF-8?Q?ami=5Fstuff?= To: gcc@gcc.gnu.org Mime-Version: 1.0 Message-ID: <57be0fcf.7526396c.4a703562.deb8b@o2.pl> Date: Wed, 29 Jul 2009 11:41:00 -0000 X-Originator: 212.67.149.145 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: 2009-07/txt/msg00600.txt.bz2 Hi, Here is a C source code which I compiled with GCC 3.4.0 and GCC 4.4.0. GCC = 3.4.0 output looks a lot better. #include #include #define umul_ppmm(xh, xl, a, b) \ __asm__ ("| Inlined umul_ppmm\n" \ " move.l %0,%/d5\n" \ " move.l %1,%/d4\n" \ " moveq #16,%/d3\n" \ " move.l %0,%/d2\n" \ " mulu %1,%0\n" \ " lsr.l %/d3,%/d4\n" \ " lsr.l %/d3,%/d5\n" \ " mulu %/d4,%/d2\n" \ " mulu %/d5,%1\n" \ " mulu %/d5,%/d4\n" \ " move.l %/d2,%/d5\n" \ " lsr.l %/d3,%/d2\n" \ " add.w %1,%/d5\n" \ " addx.l %/d2,%/d4\n" \ " lsl.l %/d3,%/d5\n" \ " lsr.l %/d3,%1\n" \ " add.l %/d5,%0\n" \ " addx.l %/d4,%1" \ : "=3Dd" ((uint32_t) (xl)), "=3Dd" ((uint32_t) (xh)) \ : "0" ((uint32_t) (a)), "1" ((uint32_t) (b)) \ : "d2", "d3", "d4", "d5") inline int64_t MUL64(int a, int b) { uint32_t au =3D a; uint32_t bu =3D b; uint32_t resh, resl; uint64_t res; umul_ppmm(resh, resl, au, bu); if (a < 0) resh -=3D bu; if (b < 0) resh -=3D au; res =3D ((uint64_t)resh << 32) | resl; return res; }=20 GCC 4.4.0 asm output: #NO_APP .text .even .globl _MUL64 _MUL64: movem.l #16128,-(sp) move.l 28(sp),d0 move.l 32(sp),a0 move.l d0,d6 move.l a0,d1 #APP ;# 36 "mul642.c" 1 | Inlined umul_ppmm move.l d6,d5 move.l d1,d4 moveq #16,d3 move.l d6,d2 mulu d1,d6 lsr.l d3,d4 lsr.l d3,d5 mulu d4,d2 mulu d5,d1 mulu d5,d4 move.l d2,d5 lsr.l d3,d2 add.w d1,d5 addx.l d2,d4 lsl.l d3,d5 lsr.l d3,d1 add.l d5,d6 addx.l d4,d1 #NO_APP tst.l d0 jlt L6 tst.l a0 jlt L7 L3: move.l d1,d2 clr.l d3 move.l d2,d0 move.l d3,d1 or.l d6,d1 move.l d0,d6 move.l d1,d7 move.l d7,d1 movem.l (sp)+,#252 rts L7: sub.l d0,d1 move.l d1,d2 clr.l d3 move.l d2,d0 move.l d3,d1 or.l d6,d1 move.l d0,d6 move.l d1,d7 move.l d7,d1 movem.l (sp)+,#252 rts L6: sub.l a0,d1 tst.l a0 jge L3 jra L7=20 GCC 3.4.0 asm output: #NO_APP .text .even .globl _MUL64 _MUL64: moveml #0x3f00,sp@- movel sp@(28),d1 movel sp@(32),d0 movel d1,d7 movel d0,d6 #APP | Inlined umul_ppmm move.l d7,d5 move.l d6,d4 moveq #16,d3 move.l d7,d2 mulu d6,d7 lsr.l d3,d4 lsr.l d3,d5 mulu d4,d2 mulu d5,d6 mulu d5,d4 move.l d2,d5 lsr.l d3,d2 add.w d6,d5 addx.l d2,d4 lsl.l d3,d5 lsr.l d3,d6 add.l d5,d7 addx.l d4,d6 #NO_APP tstl d1 jlt L5 tstl d0 jge L3 jra L6 .even L5: subl d0,d6 tstl d0 jge L3 .even L6: subl d1,d6 .even L3: movel d6,d0 clrl d1 orl d7,d1 moveml sp@+,#0xfc rts=20 Is it a regression? Regards