--- a/hotspot/src/cpu/sparc/vm/sparc.ad Tue Dec 18 17:37:44 2012 -0800
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad Wed Dec 19 14:44:00 2012 -0800
@@ -10224,7 +10224,7 @@
//---------- Zeros Count Instructions ------------------------------------------
-instruct countLeadingZerosI(iRegI dst, iRegI src, iRegI tmp, flagsReg cr) %{
+instruct countLeadingZerosI(iRegIsafe dst, iRegI src, iRegI tmp, flagsReg cr) %{
predicate(UsePopCountInstruction); // See Matcher::match_rule_supported
match(Set dst (CountLeadingZerosI src));
effect(TEMP dst, TEMP tmp, KILL cr);
@@ -10321,7 +10321,7 @@
ins_pipe(ialu_reg);
%}
-instruct countTrailingZerosI(iRegI dst, iRegI src, flagsReg cr) %{
+instruct countTrailingZerosI(iRegIsafe dst, iRegI src, flagsReg cr) %{
predicate(UsePopCountInstruction); // See Matcher::match_rule_supported
match(Set dst (CountTrailingZerosI src));
effect(TEMP dst, KILL cr);
@@ -10364,19 +10364,21 @@
//---------- Population Count Instructions -------------------------------------
-instruct popCountI(iRegI dst, iRegI src) %{
+instruct popCountI(iRegIsafe dst, iRegI src) %{
predicate(UsePopCountInstruction);
match(Set dst (PopCountI src));
- format %{ "POPC $src, $dst" %}
- ins_encode %{
- __ popc($src$$Register, $dst$$Register);
+ format %{ "SRL $src, G0, $dst\t! clear upper word for 64 bit POPC\n\t"
+ "POPC $dst, $dst" %}
+ ins_encode %{
+ __ srl($src$$Register, G0, $dst$$Register);
+ __ popc($dst$$Register, $dst$$Register);
%}
ins_pipe(ialu_reg);
%}
// Note: Long.bitCount(long) returns an int.
-instruct popCountL(iRegI dst, iRegL src) %{
+instruct popCountL(iRegIsafe dst, iRegL src) %{
predicate(UsePopCountInstruction);
match(Set dst (PopCountL src));