Print this page
*** NO COMMENTS ***
*** 1865,1874 ****
--- 1865,1877 ----
return false;
switch (opcode) {
case Op_CountLeadingZerosI:
case Op_CountLeadingZerosL:
+ if (!(UsePopCountInstruction || UseCountLeadingZerosInstruction))
+ return false;
+ break;
case Op_CountTrailingZerosI:
case Op_CountTrailingZerosL:
case Op_PopCountI:
case Op_PopCountL:
if (!UsePopCountInstruction)
*** 10352,10362 ****
//---------- Zeros Count Instructions ------------------------------------------
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);
// x |= (x >> 1);
// x |= (x >> 2);
--- 10355,10365 ----
//---------- Zeros Count Instructions ------------------------------------------
instruct countLeadingZerosI(iRegIsafe dst, iRegI src, iRegI tmp, flagsReg cr) %{
! predicate(UsePopCountInstruction && !UseCountLeadingZerosInstruction); // See Matcher::match_rule_supported
match(Set dst (CountLeadingZerosI src));
effect(TEMP dst, TEMP tmp, KILL cr);
// x |= (x >> 1);
// x |= (x >> 2);
*** 10399,10409 ****
%}
ins_pipe(ialu_reg);
%}
instruct countLeadingZerosL(iRegIsafe dst, iRegL src, iRegL tmp, flagsReg cr) %{
! predicate(UsePopCountInstruction); // See Matcher::match_rule_supported
match(Set dst (CountLeadingZerosL src));
effect(TEMP dst, TEMP tmp, KILL cr);
// x |= (x >> 1);
// x |= (x >> 2);
--- 10402,10412 ----
%}
ins_pipe(ialu_reg);
%}
instruct countLeadingZerosL(iRegIsafe dst, iRegL src, iRegL tmp, flagsReg cr) %{
! predicate(UsePopCountInstruction && !UseCountLeadingZerosInstruction);
match(Set dst (CountLeadingZerosL src));
effect(TEMP dst, TEMP tmp, KILL cr);
// x |= (x >> 1);
// x |= (x >> 2);
*** 10446,10455 ****
--- 10449,10490 ----
__ popc(Rdst, Rdst);
__ mov(BitsPerLong, Rtmp);
__ sub(Rtmp, Rdst, Rdst);
%}
ins_pipe(ialu_reg);
+ %}
+
+ instruct countLeadingZerosIvis(iRegIsafe dst, iRegI src) %{
+ predicate(UseCountLeadingZerosInstruction);
+ match(Set dst (CountLeadingZerosI src));
+ effect(TEMP dst);
+
+ format %{ "SRL $src,0,$dst\t! count leading zeros (int)\n\t"
+ "LZCNT $dst,$dst\n\t"
+ "SUB $dst,32,$dst" %}
+ ins_encode %{
+ Register Rdst = $dst$$Register;
+ Register Rsrc = $src$$Register;
+ __ srl(Rsrc, 0, Rdst);
+ __ lzcnt(Rdst, Rdst);
+ __ sub(Rdst, BitsPerInt, Rdst);
+ %}
+ ins_pipe(ialu_reg);
+ %}
+
+ instruct countLeadingZerosLvis(iRegIsafe dst, iRegL src) %{
+ predicate(UseCountLeadingZerosInstruction);
+ match(Set dst (CountLeadingZerosL src));
+ effect(TEMP dst);
+
+ format %{ "LZCNT $src,$dst\t! count leading zeros (long)" %}
+ ins_encode %{
+ Register Rdst = $dst$$Register;
+ Register Rsrc = $src$$Register;
+ __ lzcnt(Rsrc, Rdst);
+ %}
+ ins_pipe(ialu_reg);
%}
instruct countTrailingZerosI(iRegIsafe dst, iRegI src, flagsReg cr) %{
predicate(UsePopCountInstruction); // See Matcher::match_rule_supported
match(Set dst (CountTrailingZerosI src));