-
Notifications
You must be signed in to change notification settings - Fork 5.9k
8324720: Instruction selection does not respect -XX:-UseBMI2Instructions flag #25415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back sarannat! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
/cc hotspot-compiler |
@robcasloz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change affects the final value of UseBMI2Instructions
when the JVM is run with its default configuration on machines without AVX-512 (i.e. UseAVX
<= 2), I guess that is unexpected?
My CPU flags:
$ cat /proc/cpuinfo | grep flags
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp vnmi md_clear flush_l1d arch_capabilities
Before this change:
$ java -XX:+PrintFlagsFinal | grep UseBMI
bool UseBMI1Instructions = true {ARCH product} {default}
bool UseBMI2Instructions = true {ARCH product} {default}
With this change:
$ java -XX:+PrintFlagsFinal --version | grep BMI
bool UseBMI1Instructions = true {ARCH product} {default}
bool UseBMI2Instructions = false {ARCH product} {default}
This seems unreasonable, you are sacrificing correctness for performance. |
Thank you for the review. My first approach to the fix was inline with your comments. I will go back and implement the changes based on this. |
Issue:
While executing a function performing
a >> b
operation with–XX:-UseBMI2Instructions
flag, the generated code contains BMI2 instructionsarx eax,esi,edx
. The expected output should not contain any BMI2 instruction.Analysis and solution
As suggested by @merykitty in JDK-8324720 , the initial idea was to make
VM_Version::supports_bmi2()
respectUseBMI2Instructions
flag by disabling BMI2 feature whenUseBMI2Instructions
runtime flag is explicitly set to false. This fix is similar to how other runtime flags such as,UseAPX
andUseAVX
, enable or disable specific code and register set. However, some test failures were encountered while running tests on this fix.The first set of failures were caused by assertion check on
VM_Version::supports_bmi2()
statement while generating some BMI2 specific instructions. This was caused by the stub generator generating AVX-512 specific code that uses these BMI2 instructions. It should be noted that theUseAVX
flag is set by default to the highest supported version available in x86 machine. This in turn allows AVX-512 specific code generation whenever possible. In order to not comprise the performance benefits of using AVX-512, the proposed fix only disables BMI2 feature if AVX-512 features are also disabled (or not available in the machine) along with the UseBMI2Instructions flag.The second failure occured in
compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnSupportedCPU.java
where a warning "Intrinsics for SHA-384 and SHA-512 crypto hash functions not available on this CPU." was returned on a AMD64 machine that had support for SHA512. Looking intocompiler/testlibrary/sha/predicate/IntrinsicPredicates.java
it was found that the predicate for AMD64 was not in line with the changes introduced by JDK-8341052 in commit 85c1aea .Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25415/head:pull/25415
$ git checkout pull/25415
Update a local copy of the PR:
$ git checkout pull/25415
$ git pull https://git.openjdk.org/jdk.git pull/25415/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25415
View PR using the GUI difftool:
$ git pr show -t 25415
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25415.diff
Using Webrev
Link to Webrev Comment