Re: [JAVA PATCH] Builtin support for popcount* and bswap* functions
Jeff Law <[email protected]> Thu, 19 May 2016 12:09:18 -0600
| Newsgroups | gmane.comp.gcc.patches,gmane.comp.gcc.java.patches |
|---|---|
| Message-ID | <[email protected]> |
On 02/22/2016 11:13 AM, [email protected] 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 <[email protected]> > > 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