On Fri, 20 Nov 2026 01:32:02 GMT, Vladimir Ivanov <[email protected]> wrote:
>> Jatin Bhateja has updated the pull request with a new target base due to a >> merge or a rebase. The incremental webrev excludes the unrelated changes >> brought in by the merge/rebase. The pull request contains four additional >> commits since the last revision: >> >> - Merge branch 'master' of http://github.com/openjdk/jdk into JDK-8393511 >> - Review comments resolution >> - Adding comments >> - 8393511: Optimize x86 vector count trailing zeros using popcount >> instructions > > Overall, looks good. > > I don't see any test cases introduced. Does it make sense to validate new > shape with targeted IR tests? > > Minor questions/suggestions follow. Hi @iwanowww , your comment have been addressed. > src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp line 6237: > >> 6235: // CTZ = POPC((x - 1) & ~x) >> 6236: // Ref: "Hacker's Delight" by Henry Warren >> 6237: void >> C2_MacroAssembler::vector_count_trailing_zeros_evex_popc(BasicType bt, >> XMMRegister dst, XMMRegister src, > > Any particular reason to introduce > `C2_MacroAssembler::vector_count_trailing_zeros_evex_popc()`? If it is not > intended to be shared, why not simply putting it inside > `vcount_trailing_zeros_popcnt_evex`? Addressed > src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp line 6247: > >> 6245: vpadd(bt, xtmp, xtmp, src, vec_enc); >> 6246: // xtmp = xtmp & ~src >> 6247: vpternlogd(xtmp, 0x40, xtmp, src, vec_enc); > > Any particular reason to use `vpternlogd` here? `vpandn` does the job and is > slightly more compact, isn't it? Done > src/hotspot/cpu/x86/x86.ad line 2882: > >> 2880: >> 2881: static inline bool is_vector_ctz_popcnt_evex(BasicType bt, int >> vlen_bytes) { >> 2882: if (!(bt == T_BYTE || bt == T_SHORT || bt == T_INT || bt == T_LONG)) >> { > > Nit: I suggest to revert it. IMO it becomes easier to follow the logic. > > if (bt == T_BYTE || bt == T_SHORT || bt == T_INT || bt == T_LONG) { > return is_vector_popcount_predicate(bt) && > (VM_Version::supports_avx512vl() || vlen_bytes == 64); > } > return false; > ``` > > Also, predicate can be simplified by passing `n->in(1)` into the helper: > > static inline bool is_vector_ctz_popcnt_evex(Node* n) { > assert(n->bottom_type()->isa_vect(), "not a vector"); > BasicType bt = Matcher::vector_element_basic_type(n); > int vlen_bytes = Matcher::vector_length_in_bytes(n); > ... > } > ... > predicate(is_vector_ctz_popcnt_evex(n->in(1))); Done ------------- PR Comment: https://git.openjdk.org/jdk/pull/33863#issuecomment-7033154545 PR Review Comment: https://git.openjdk.org/jdk/pull/33863#discussion_r4639569625 PR Review Comment: https://git.openjdk.org/jdk/pull/33863#discussion_r4639570279 PR Review Comment: https://git.openjdk.org/jdk/pull/33863#discussion_r4639568903
