RFR: 8265491: Math Signum optimization for x86 [v5]

Marcus G K Williams github.com+168222+mgkwill at openjdk.java.net
Thu Apr 22 19:02:24 UTC 2021


On Wed, 21 Apr 2021 23:53:50 GMT, Jie Fu <jiefu at openjdk.org> wrote:

>> Marcus G K Williams has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Reorder jcc equal,parity
>>    
>>    Signed-off-by: Marcus G K Williams <marcus.williams at intel.com>
>>  - Use xorp to negate 1
>>    
>>    Signed-off-by: Marcus G K Williams <marcus.williams at intel.com>
>
> src/hotspot/cpu/x86/vm_version_x86.cpp line 1703:
> 
>> 1701:   }
>> 1702: #endif // !PRODUCT
>> 1703:   if (FLAG_IS_DEFAULT(UseSignumIntrinsic) && (UseSSE >= 2)) {
> 
> `UseSSE >=2` looks a bit uncomfortable to me since signumF_reg only requires UseSSE>=1. 
> 
> How about something like this:
> 
> diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad
> index bbf5256c112..0a738704c4d 100644
> --- a/src/hotspot/cpu/x86/x86.ad
> +++ b/src/hotspot/cpu/x86/x86.ad
> @@ -1598,6 +1598,16 @@ const bool Matcher::match_rule_supported(int opcode) {
>          return false;
>        }
>        break;
> +    case Op_SignumF:
> +      if (UseSSE < 1) {
> +        return false;
> +      }
> +      break;
> +    case Op_SignumD:
> +      if (UseSSE < 2) {
> +        return false;
> +      }
> +      break;
>  #endif // !LP64
>    }
>    return true;  // Match rules are supported by default.
> diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp
> index 7cb7955c612..217ee39d709 100644
> --- a/src/hotspot/share/opto/library_call.cpp
> +++ b/src/hotspot/share/opto/library_call.cpp
> @@ -1737,8 +1737,8 @@ bool LibraryCallKit::inline_math_native(vmIntrinsics::ID id) {
>    case vmIntrinsics::_dpow:      return inline_math_pow();
>    case vmIntrinsics::_dcopySign: return inline_double_math(id);
>    case vmIntrinsics::_fcopySign: return inline_math(id);
> -  case vmIntrinsics::_dsignum: return inline_double_math(id);
> -  case vmIntrinsics::_fsignum: return inline_math(id);
> +  case vmIntrinsics::_dsignum: return Matcher::match_rule_supported(Op_SignumD) ? inline_double_math(id) : false;
> +  case vmIntrinsics::_fsignum: return Matcher::match_rule_supported(Op_SignumF) ? inline_math(id) : false;
>  
>     // These intrinsics are not yet correctly implemented
>    case vmIntrinsics::_datan2:
> 
> 
> In this way, we can enable UseSignumIntrinsic by default on x86.
> Thanks.

Thanks for the suggestion. This looks good as long as it doesn't affect aarch64.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3581


More information about the hotspot-compiler-dev mailing list