JDK-8005033 : clear high word for integer pop count on SPARC
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: sparc
  • Submitted: 2012-12-13
  • Updated: 2013-06-26
  • Resolved: 2012-12-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8 Other
7u40Fixed 8Fixed hs24Fixed


I would like to submit a bugfix for C2's Integer.bitCount() intrinsic on sparcv9.

On sparcv9, the C2 intrinsic for Integer.bitCount() is a POPC instruction. POPC operates on the whole register, including the high word, but for Integer.bitCount(), this is not correct, because the value of the high word is undefined. There could be bits set as a result of an int overflow or from a shift operation for example. Of course the bits in the high word have to be ignored for Integer.bitCount().

I have prepared a small webrev with the suggested fix and a regression test:


Could you please review the patch and create a bug id? Thanks!

The SPARC instruction set manual states: Programming Note: POPC is a ���64-bit-only��� instruction; there is no version of this instruction that operates on just the less-significant 32 bits of its source operand.