From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 118150 invoked by alias); 19 May 2016 18:09:32 -0000 Mailing-List: contact java-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-patches-owner@gcc.gnu.org Received: (qmail 118114 invoked by uid 89); 19 May 2016 18:09:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=centre, Centre, roger, Roger X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 19 May 2016 18:09:21 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7FC5AC01B14E; Thu, 19 May 2016 18:09:19 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-172.phx2.redhat.com [10.3.116.172]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4JI9IJ2009780; Thu, 19 May 2016 14:09:19 -0400 Subject: Re: [JAVA PATCH] Builtin support for popcount* and bswap* functions To: "roger@nextmovesoftware.com" , java-patches@gcc.gnu.org, gcc-patches@gcc.gnu.org References: From: Jeff Law Message-ID: <106cccd3-68ed-6df7-1915-10cb817936a3@redhat.com> Date: Thu, 19 May 2016 18:09:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2016-q2/txt/msg00016.txt.bz2 On 02/22/2016 11:13 AM, roger@nextmovesoftware.com wrote: > > The following patch provides builtin support for byte swapping and bit counting. > On suitable hardware, these generate the x86 popcount instructions, as also > generated by the SUN HotSpot JIT/JVM for these method calls. > > java.lang.Integer.bitCount -> __builtin_popcount > java.lang.Long.bitCount -> __builtin_popcountl > > java.lang.Short.reverseBytes -> __builtin_bswap16 > java.lang.Integer.reverseBytes -> __builtin_bswap32 > java.lang.Long.reverseBytes -> __builtin_bswap64 > > New test cases have been added to libjava to double check nothing breaks. > Whist I was there I noticed that the math builtins (many of which I added support for > back in 2003/2004) weren't marked as ECF_LEAF, indicating that they don't/can't > invoke any user specified functions. This has also been fixed in the patch below. > > The following patch has been tested on x86_64-pc-linux-gnu with a full make bootstrap > and make check with no new failures/regressions. > > Ok for stage1 once it reopens? > > Cheers, > > Roger > -- > Roger Sayle, Ph.D. > CEO and founder > NextMove Software Limited > Registered in England No. 07588305 > Registered Office: Innovation Centre (Unit 23), Cambridge Science Park, Cambridge CB4 0EY > > 2016-02-21 Roger Sayle > > gcc/java: > * builtins.c (java_builtins): Use popcount* and bswap* builtins to > implement bitCount() and reverseBytes() methods in java.lang.Integer > and friends. > (initialize_builtins): Annotate math builtins with ECF_LEAF. Call > define_builtin for the new popcount* and bswap* builtins. > > libjava: > * testsuite/libjava.lang/BuiltinBitCount.java: New test case. > * testsuite/libjava.lang/BuiltinReverseBytes.java: Likewise. OK for the trunk. Thanks, Jeff