Print this page
*** NO COMMENTS ***

Split Close
Expand all
Collapse all
          --- old/src/cpu/sparc/vm/sparc.ad
          +++ new/src/cpu/sparc/vm/sparc.ad
↓ open down ↓ 1859 lines elided ↑ open up ↑
1860 1860    return as_DoubleFloatRegister(register_encoding);
1861 1861  }
1862 1862  
1863 1863  const bool Matcher::match_rule_supported(int opcode) {
1864 1864    if (!has_match_rule(opcode))
1865 1865      return false;
1866 1866  
1867 1867    switch (opcode) {
1868 1868    case Op_CountLeadingZerosI:
1869 1869    case Op_CountLeadingZerosL:
     1870 +    if (!(UsePopCountInstruction || UseCountLeadingZerosInstruction))
     1871 +        return false;
     1872 +    break;
1870 1873    case Op_CountTrailingZerosI:
1871 1874    case Op_CountTrailingZerosL:
1872 1875    case Op_PopCountI:
1873 1876    case Op_PopCountL:
1874 1877      if (!UsePopCountInstruction)
1875 1878        return false;
1876 1879    case Op_CompareAndSwapL:
1877 1880  #ifdef _LP64
1878 1881    case Op_CompareAndSwapP:
1879 1882  #endif
↓ open down ↓ 8467 lines elided ↑ open up ↑
10347 10350      __ string_inflate($src$$Register, $dst$$Register, $len$$Register, $tmp$$Register, Ldone);
10348 10351      __ bind(Ldone);
10349 10352    %}
10350 10353    ins_pipe(long_memory_op);
10351 10354  %}
10352 10355  
10353 10356  
10354 10357  //---------- Zeros Count Instructions ------------------------------------------
10355 10358  
10356 10359  instruct countLeadingZerosI(iRegIsafe dst, iRegI src, iRegI tmp, flagsReg cr) %{
10357      -  predicate(UsePopCountInstruction);  // See Matcher::match_rule_supported
     10360 +  predicate(UsePopCountInstruction && !UseCountLeadingZerosInstruction);  // See Matcher::match_rule_supported
10358 10361    match(Set dst (CountLeadingZerosI src));
10359 10362    effect(TEMP dst, TEMP tmp, KILL cr);
10360 10363  
10361 10364    // x |= (x >> 1);
10362 10365    // x |= (x >> 2);
10363 10366    // x |= (x >> 4);
10364 10367    // x |= (x >> 8);
10365 10368    // x |= (x >> 16);
10366 10369    // return (WORDBITS - popc(x));
10367 10370    format %{ "SRL     $src,1,$tmp\t! count leading zeros (int)\n\t"
↓ open down ↓ 26 lines elided ↑ open up ↑
10394 10397      __ srl(Rdst, 16,   Rtmp);
10395 10398      __ or3(Rdst, Rtmp, Rdst);
10396 10399      __ popc(Rdst, Rdst);
10397 10400      __ mov(BitsPerInt, Rtmp);
10398 10401      __ sub(Rtmp, Rdst, Rdst);
10399 10402    %}
10400 10403    ins_pipe(ialu_reg);
10401 10404  %}
10402 10405  
10403 10406  instruct countLeadingZerosL(iRegIsafe dst, iRegL src, iRegL tmp, flagsReg cr) %{
10404      -  predicate(UsePopCountInstruction);  // See Matcher::match_rule_supported
     10407 +  predicate(UsePopCountInstruction && !UseCountLeadingZerosInstruction);
10405 10408    match(Set dst (CountLeadingZerosL src));
10406 10409    effect(TEMP dst, TEMP tmp, KILL cr);
10407 10410  
10408 10411    // x |= (x >> 1);
10409 10412    // x |= (x >> 2);
10410 10413    // x |= (x >> 4);
10411 10414    // x |= (x >> 8);
10412 10415    // x |= (x >> 16);
10413 10416    // x |= (x >> 32);
10414 10417    // return (WORDBITS - popc(x));
↓ open down ↓ 26 lines elided ↑ open up ↑
10441 10444      __ or3( Rdst, Rtmp, Rdst);
10442 10445      __ srlx(Rdst, 16,   Rtmp);
10443 10446      __ or3( Rdst, Rtmp, Rdst);
10444 10447      __ srlx(Rdst, 32,   Rtmp);
10445 10448      __ or3( Rdst, Rtmp, Rdst);
10446 10449      __ popc(Rdst, Rdst);
10447 10450      __ mov(BitsPerLong, Rtmp);
10448 10451      __ sub(Rtmp, Rdst, Rdst);
10449 10452    %}
10450 10453    ins_pipe(ialu_reg);
     10454 +%}
     10455 +
     10456 +instruct countLeadingZerosIvis(iRegIsafe dst, iRegI src) %{
     10457 +  predicate(UseCountLeadingZerosInstruction);
     10458 +  match(Set dst (CountLeadingZerosI src));
     10459 +  effect(TEMP dst);
     10460 +
     10461 +  format %{ "SRL    $src,0,$dst\t! count leading zeros (int)\n\t"
     10462 +            "LZCNT  $dst,$dst\n\t"
     10463 +            "SUB    $dst,32,$dst" %}
     10464 +  ins_encode %{
     10465 +    Register Rdst = $dst$$Register;
     10466 +    Register Rsrc = $src$$Register;
     10467 +    __ srl(Rsrc, 0, Rdst);
     10468 +    __ lzcnt(Rdst, Rdst);
     10469 +    __ sub(Rdst, BitsPerInt, Rdst);
     10470 +  %}
     10471 +  ins_pipe(ialu_reg);
     10472 +%}
     10473 +
     10474 +instruct countLeadingZerosLvis(iRegIsafe dst, iRegL src) %{
     10475 +  predicate(UseCountLeadingZerosInstruction);
     10476 +  match(Set dst (CountLeadingZerosL src));
     10477 +  effect(TEMP dst);
     10478 +
     10479 +  format %{ "LZCNT  $src,$dst\t! count leading zeros (long)" %}
     10480 +  ins_encode %{
     10481 +    Register Rdst = $dst$$Register;
     10482 +    Register Rsrc = $src$$Register;
     10483 +    __ lzcnt(Rsrc, Rdst);
     10484 +  %}
     10485 +  ins_pipe(ialu_reg);
10451 10486  %}
10452 10487  
10453 10488  instruct countTrailingZerosI(iRegIsafe dst, iRegI src, flagsReg cr) %{
10454 10489    predicate(UsePopCountInstruction);  // See Matcher::match_rule_supported
10455 10490    match(Set dst (CountTrailingZerosI src));
10456 10491    effect(TEMP dst, KILL cr);
10457 10492  
10458 10493    // return popc(~x & (x - 1));
10459 10494    format %{ "SUB     $src,1,$dst\t! count trailing zeros (int)\n\t"
10460 10495              "ANDN    $dst,$src,$dst\n\t"
↓ open down ↓ 623 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX