10222 %} |
10222 %} |
10223 |
10223 |
10224 |
10224 |
10225 //---------- Zeros Count Instructions ------------------------------------------ |
10225 //---------- Zeros Count Instructions ------------------------------------------ |
10226 |
10226 |
10227 instruct countLeadingZerosI(iRegI dst, iRegI src, iRegI tmp, flagsReg cr) %{ |
10227 instruct countLeadingZerosI(iRegIsafe dst, iRegI src, iRegI tmp, flagsReg cr) %{ |
10228 predicate(UsePopCountInstruction); // See Matcher::match_rule_supported |
10228 predicate(UsePopCountInstruction); // See Matcher::match_rule_supported |
10229 match(Set dst (CountLeadingZerosI src)); |
10229 match(Set dst (CountLeadingZerosI src)); |
10230 effect(TEMP dst, TEMP tmp, KILL cr); |
10230 effect(TEMP dst, TEMP tmp, KILL cr); |
10231 |
10231 |
10232 // x |= (x >> 1); |
10232 // x |= (x >> 1); |
10319 __ sub(Rtmp, Rdst, Rdst); |
10319 __ sub(Rtmp, Rdst, Rdst); |
10320 %} |
10320 %} |
10321 ins_pipe(ialu_reg); |
10321 ins_pipe(ialu_reg); |
10322 %} |
10322 %} |
10323 |
10323 |
10324 instruct countTrailingZerosI(iRegI dst, iRegI src, flagsReg cr) %{ |
10324 instruct countTrailingZerosI(iRegIsafe dst, iRegI src, flagsReg cr) %{ |
10325 predicate(UsePopCountInstruction); // See Matcher::match_rule_supported |
10325 predicate(UsePopCountInstruction); // See Matcher::match_rule_supported |
10326 match(Set dst (CountTrailingZerosI src)); |
10326 match(Set dst (CountTrailingZerosI src)); |
10327 effect(TEMP dst, KILL cr); |
10327 effect(TEMP dst, KILL cr); |
10328 |
10328 |
10329 // return popc(~x & (x - 1)); |
10329 // return popc(~x & (x - 1)); |
10362 %} |
10362 %} |
10363 |
10363 |
10364 |
10364 |
10365 //---------- Population Count Instructions ------------------------------------- |
10365 //---------- Population Count Instructions ------------------------------------- |
10366 |
10366 |
10367 instruct popCountI(iRegI dst, iRegI src) %{ |
10367 instruct popCountI(iRegIsafe dst, iRegI src) %{ |
10368 predicate(UsePopCountInstruction); |
10368 predicate(UsePopCountInstruction); |
10369 match(Set dst (PopCountI src)); |
10369 match(Set dst (PopCountI src)); |
10370 |
10370 |
10371 format %{ "POPC $src, $dst" %} |
10371 format %{ "SRL $src, G0, $dst\t! clear upper word for 64 bit POPC\n\t" |
10372 ins_encode %{ |
10372 "POPC $dst, $dst" %} |
10373 __ popc($src$$Register, $dst$$Register); |
10373 ins_encode %{ |
|
10374 __ srl($src$$Register, G0, $dst$$Register); |
|
10375 __ popc($dst$$Register, $dst$$Register); |
10374 %} |
10376 %} |
10375 ins_pipe(ialu_reg); |
10377 ins_pipe(ialu_reg); |
10376 %} |
10378 %} |
10377 |
10379 |
10378 // Note: Long.bitCount(long) returns an int. |
10380 // Note: Long.bitCount(long) returns an int. |
10379 instruct popCountL(iRegI dst, iRegL src) %{ |
10381 instruct popCountL(iRegIsafe dst, iRegL src) %{ |
10380 predicate(UsePopCountInstruction); |
10382 predicate(UsePopCountInstruction); |
10381 match(Set dst (PopCountL src)); |
10383 match(Set dst (PopCountL src)); |
10382 |
10384 |
10383 format %{ "POPC $src, $dst" %} |
10385 format %{ "POPC $src, $dst" %} |
10384 ins_encode %{ |
10386 ins_encode %{ |