-
Bug
-
Resolution: Unresolved
-
P4
-
21, 22, 23
-
x86
(Noticed by Joel Rudsberg during manual code inspection.)
Run the following test with:
$ java -Xcomp -XX:-UseBMI2Instructions -XX:CompileCommand=print,BMI.shift -XX:CompileCommand=dontinline,BMI.shift BMI.java
class BMI {
static int shift(int a, int b) {
return a >> b;
}
public static void main(String[] args) {
shift(42, 23);
}
}
Expected: no BMI2 instructions in the generated code
Actual: the generated code contains the BMI2 instruction sarx eax,esi,edx
I believe the reason is that the definition of sarx and other BMI2 instructions in hotspot/cpu/x86/x86_64.ad is guarded by:
predicate(VM_Version::supports_bmi2());
which only checks the host CPU's flags. In contrast, BMI1 instructions in the same file are guarded by:
predicate(UseBMI1Instructions);
I believe the fix is to replace the predicates for BMI2 instructions with the corresponding
predicate(UseBMI2Instructions);
I can put together a PR if someone can confirm that this would be the correct fix.
Run the following test with:
$ java -Xcomp -XX:-UseBMI2Instructions -XX:CompileCommand=print,BMI.shift -XX:CompileCommand=dontinline,BMI.shift BMI.java
class BMI {
static int shift(int a, int b) {
return a >> b;
}
public static void main(String[] args) {
shift(42, 23);
}
}
Expected: no BMI2 instructions in the generated code
Actual: the generated code contains the BMI2 instruction sarx eax,esi,edx
I believe the reason is that the definition of sarx and other BMI2 instructions in hotspot/cpu/x86/x86_64.ad is guarded by:
predicate(VM_Version::supports_bmi2());
which only checks the host CPU's flags. In contrast, BMI1 instructions in the same file are guarded by:
predicate(UseBMI1Instructions);
I believe the fix is to replace the predicates for BMI2 instructions with the corresponding
predicate(UseBMI2Instructions);
I can put together a PR if someone can confirm that this would be the correct fix.
- relates to
-
JDK-8283694 Improve bit manipulation and boolean to integer conversion operations on x86_64
- Resolved