From patchwork Tue Jan 31 05:15:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138687 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C5B0B1007D1 for ; Tue, 31 Jan 2012 16:15:51 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1328591752; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=7zsj4VmeyaAUaxd2lfDeW6KumKs=; b=LqdiXs3rYoOCCrO HREAdjcWZvGQ/3/6OwEboYPrax7M/rOi+hcM6AjrH5Ne/HuWACtYMr/T0EWiL7nH sQheFqieSfdtZRjVmMlq1dHDzCY4vvBlQYavxxEHI/xqreJhkdmwoCnFr/3XNafy HDOUeWCD30uqEVq2HzddAg82le1Y= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Content-Transfer-Encoding:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=QStIXZyBRl/pbFChlkYoJax99W3h5mDVyng2kDcNwEQ/mLRD2U8J0Jv3eHf0ZH laOXxW8Toi+akHI/O8YI3QyUkCkJ1j/TBcgcVgqo5htznuhq9z0ffyPUmjCY8HrE shrX7cAb/UQ/HRksme3VYit7aGxt8OlwuP4DZC+eEfTHg=; Received: (qmail 8301 invoked by alias); 31 Jan 2012 05:15:44 -0000 Received: (qmail 8285 invoked by uid 22791); 31 Jan 2012 05:15:40 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_CL, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 31 Jan 2012 05:15:25 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0V5FP0H007466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 31 Jan 2012 00:15:25 -0500 Received: from pebble.twiddle.net (vpn1-51-45.bne.redhat.com [10.64.51.45]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0V5FNbc027330 for ; Tue, 31 Jan 2012 00:15:24 -0500 Message-ID: <4F2778EA.7060009@redhat.com> Date: Tue, 31 Jan 2012 16:15:22 +1100 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: GCC Patches Subject: [arm] Improve longlong.h umul_ppmm, count_trailing_zeros X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org I noticed this accidentally, while looking for something else. There are significant improvements in the DImode multiplication and division routines for armv4+. Despite how trivial this is, I assume this must wait for stage1. Ok? r~ * longlong.h [arm] (umul_ppmm): Use umull. [arm] (count_trailing_zeros): Use __builtin_ctz. diff --git a/libgcc/longlong.h b/libgcc/longlong.h index 30cc2e3..7204679 100644 --- a/libgcc/longlong.h +++ b/libgcc/longlong.h @@ -220,9 +220,12 @@ UDItype __umulsidi3 (USItype, USItype); "rI" ((USItype) (bh)), \ "r" ((USItype) (al)), \ "rI" ((USItype) (bl)) __CLOBBER_CC) -#define umul_ppmm(xh, xl, a, b) \ -{register USItype __t0, __t1, __t2; \ - __asm__ ("%@ Inlined umul_ppmm\n" \ +# if defined(__ARM_ARCH_2__) || defined(__ARM_ARCH_2A__) \ + || defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__) +# define umul_ppmm(xh, xl, a, b) \ + do { \ + register USItype __t0, __t1, __t2; \ + __asm__ ("%@ Inlined umul_ppmm\n" \ " mov %2, %5, lsr #16\n" \ " mov %0, %6, lsr #16\n" \ " bic %3, %5, %2, lsl #16\n" \ @@ -239,14 +242,26 @@ UDItype __umulsidi3 (USItype, USItype); "=r" ((USItype) (xl)), \ "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \ : "r" ((USItype) (a)), \ - "r" ((USItype) (b)) __CLOBBER_CC );} -#define UMUL_TIME 20 -#define UDIV_TIME 100 + "r" ((USItype) (b)) __CLOBBER_CC ); \ + } while (0) +# define UMUL_TIME 20 +# else +# define umul_ppmm(xh, xl, a, b) \ + do { \ + /* Generate umull, under compiler control. */ \ + register UDItype __t0 = (UDItype)(USItype)(a) * (USItype)(b); \ + (xl) = (USItype)__t0; \ + (xh) = (USItype)(__t0 >> 32); \ + } while (0) +# define UMUL_TIME 3 +# endif +# define UDIV_TIME 100 #endif /* __arm__ */ #if defined(__arm__) /* Let gcc decide how best to implement count_leading_zeros. */ #define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X)) +#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctz (X)) #define COUNT_LEADING_ZEROS_0 32 #endif