JDK-8198251 : [Graal] compiler/intrinsics/bmi/verifycode tests fail with Graal on macos
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9,10,11
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-02-15
  • Updated: 2018-03-12
  • Resolved: 2018-02-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11 b03Fixed
Related Reports
Relates :  
Relates :  
Description
The following list of BMI tests fail when running in Graal JIT mode on macos:
 compiler/intrinsics/bmi/verifycode/AndnTestI.java               
 compiler/intrinsics/bmi/verifycode/AndnTestL.java               
 compiler/intrinsics/bmi/verifycode/BlsiTestI.java               
 compiler/intrinsics/bmi/verifycode/BlsiTestL.java               
 compiler/intrinsics/bmi/verifycode/BlsmskTestI.java             
 compiler/intrinsics/bmi/verifycode/BlsmskTestL.java             
 compiler/intrinsics/bmi/verifycode/BlsrTestI.java               
 compiler/intrinsics/bmi/verifycode/BlsrTestL.java


Example of compiler/intrinsics/bmi/verifycode/AndnTestI.java failure:
 TEST CASE:public int compiler.intrinsics.bmi.TestAndnI$AndnIExpr.intExpr(compiler.intrinsics.bmi.Expr$MemI,compiler.intrinsics.bmi.Expr$MemI)
public int compiler.intrinsics.bmi.TestAndnI$AndnIExpr.intExpr(compiler.intrinsics.bmi.Expr$MemI,compiler.intrinsics.bmi.Expr$MemI)
----------System.err:(17/2843)----------
java.lang.AssertionError: public int compiler.intrinsics.bmi.TestAndnI$AndnIExpr.intExpr(compiler.intrinsics.bmi.Expr$MemI,compiler.intrinsics.bmi.Expr$MemI)CPU instructions expected not found: 44 8B 56 08 49 C1 E2 03 49 3B C2 0F 85 CF 38 C1 F5 90 0F 1F 80 00 00 00 00 0F 1F 80 00 00 00 00 0F 1F 44 00 00 48 85 D2 0F 84 26 00 00 00 48 85 C9 0F 84 2F 00 00 00 8B 41 0C 44 8B 52 0C 41 F7 D2 44 23 D0 41 8B C2 49 8B 8F 80 00 00 00 85 01 C5 F8 77 C3 B8 00 00 00 00 49 8B 8F 80 00 00 00 85 01 C5 F8 77 C3 B8 00 00 00 00 49 8B 8F 80 00 00 00 85 01 C5 F8 77 C3 E8 E3 E4 DC F5 90 E8 9D 45 C1 F5 90 
	at compiler.intrinsics.bmi.verifycode.BmiIntrinsicBase.checkEmittedCode(BmiIntrinsicBase.java:109)
	at compiler.intrinsics.bmi.verifycode.BmiIntrinsicBase.compileAtLevelAndCheck(BmiIntrinsicBase.java:93)
	at compiler.intrinsics.bmi.verifycode.BmiIntrinsicBase.test(BmiIntrinsicBase.java:86)
	at compiler.intrinsics.bmi.verifycode.BmiIntrinsicBase.verifyTestCase(BmiIntrinsicBase.java:48)
	at compiler.intrinsics.bmi.verifycode.AndnTestI.main(AndnTestI.java:64)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:115)
	at java.base/java.lang.Thread.run(Thread.java:844)

Comments
Changes for JDK-8031321 were contributed by Intel when BMI instructions were introduced. It is not only Crypto. From Intel docs: "Bit manipulation instructions are useful for compressed database, hashing, large number arithmetic, and a variety of general purpose codes."
23-02-2018

Done: JDK-8198574 What was the motivation for the BMI instructions? Crypto?
22-02-2018

Okay. We should exclude these tests from Graal JIT testing (add require) for now. This will be the bug fix. [~dnsimon] Doug, can you file RFE to add these missing matcher patterns to Graal? I think Graal should support them. It is different from JDK-8193241.
22-02-2018

Yes, Graal's matcher does less than C2 so white box tests expecting code patterns generated by C2's matcher should not be applied to Graal.
22-02-2018

They are not intrinsics per se. They are C2 Matcher rules which match set of nodes into one x86 instruction: http://hg.openjdk.java.net/jdk/hs/file/9010e596f391/src/hotspot/cpu/x86/x86_64.ad#l9075 match(Set dst (AndI (XorI src1 minus_1) (LoadI src2))); andnl($dst$$Register, $src1$$Register, $src2$$Address); As I understand Graal's matcher does less than C2. May be we should change this into Enchantment as missing optimization if you, Doug, can confirm.
16-02-2018

What method intrinsic is being tested here? I'm not familiar with UseBMI1Instructions - what does it do? For reference, the set of Graal intrinsics is described in https://github.com/oracle/graal/blob/472f853b33d26bcf83b7a02aea3f2f9eafd6c7c1/compiler/src/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java.
16-02-2018

ILW = failures of bmi intrinsics tests; only with Graal; no workaround = MLH = P4 (possible testbug or related to 8193241)
16-02-2018

They are x86 tests. They should have the same results on Windows, Linux and MacOS.
15-02-2018

Note, these tests pass on macos when Graal is not used.
15-02-2018

[~dnsimon] may know if these intrinsics are supported. But tests may still fail because they look for particular assembler instructions sequence generated by C2: // from intel manual VEX.NDS.LZ.0F38.W0 F2 /r, example c4e260f2c2 instrMask = new byte[]{ (byte) 0xFF, (byte) 0x1F, (byte) 0x00, (byte) 0xFF}; instrPattern = new byte[]{ (byte) 0xC4, // prefix for 3-byte VEX instruction (byte) 0x02, // 00010 implied 0F 38 leading opcode bytes (byte) 0x00, (byte) 0xF2};
15-02-2018

Compiler team, please advise if this is expected Graal behavior or this is macos specific Graal bug.
15-02-2018

Steps to reproduce: > jtreg -jdk:build/macosx-x64/images/jdk -vmoptions:"-XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+TieredCompilation -XX:+UseJVMCICompiler -Djvmci.Compiler=graal" -dir:test/hotspot/jtreg compiler/intrinsics/bmi/verifycode/AndnTestI.java
15-02-2018