On Wed, 22 Jun 2022 03:01:36 GMT, Quan Anh Mai <d...@openjdk.org> wrote:
>> Hi, >> >> This patch implements intrinsics for `Integer/Long::compareUnsigned` using >> the same approach as the JVM does for long and floating-point comparisons. >> This allows efficient and reliable usage of unsigned comparison in Java, >> which is a basic operation and is important for range checks such as >> discussed in #8620 . >> >> Thank you very much. > > Quan Anh Mai has updated the pull request incrementally with one additional > commit since the last revision: > > add comparison for direct value of compare src/hotspot/cpu/x86/x86_64.ad line 13027: > 13025: // Manifest a CmpU result in an integer register. Very painful. > 13026: // This is the test to avoid. > 13027: instruct cmpU3_reg_reg(rRegI dst, rRegI src1, rRegI src2, rFlagsReg > flags) Do you plan to add 32 bit support? Integer pattern can be moved to common file x86.ad and 64 pattern can handled in 32/64 bit AD files. src/hotspot/cpu/x86/x86_64.ad line 13043: > 13041: __ cmpl($src1$$Register, $src2$$Register); > 13042: __ movl($dst$$Register, -1); > 13043: __ jccb(Assembler::below, done); By placing compare adjacent to conditional jump in-order frontend can trigger macro-fusion. Kindly refer section 3.4.2.2 of Intel's optimization manual. src/hotspot/cpu/x86/x86_64.ad line 13095: > 13093: __ cmpq($src1$$Register, $src2$$Register); > 13094: __ movl($dst$$Register, -1); > 13095: __ jccb(Assembler::below, done); Same as above. src/hotspot/share/opto/subnode.hpp line 185: > 183: } > 184: virtual int Opcode() const; > 185: virtual uint ideal_reg() const { return Op_RegI; } Value routine to handle constant folding. src/hotspot/share/opto/subnode.hpp line 247: > 245: init_class_id(Class_Sub); > 246: } > 247: virtual int Opcode() const; In-lining may connect the inputs to constant, hence a Value routine may be useful here. ------------- PR: https://git.openjdk.org/jdk/pull/9068