RFR: 8360192: C2: Make the type of count leading/trailing zero nodes more precise [v3]
Qizheng Xing
qxing at openjdk.org
Tue Jun 24 09:47:28 UTC 2025
On Mon, 23 Jun 2025 23:07:29 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Qizheng Xing has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Narrow type bound
>
> test/hotspot/jtreg/compiler/c2/irTests/TestCountBitsRange.java line 47:
>
>> 45: @IR(failOn = IRNode.COUNT_LEADING_ZEROS_I)
>> 46: public boolean clzCompareInt() {
>> 47: return Integer.numberOfLeadingZeros(i) < 0 || Integer.numberOfLeadingZeros(i) > 32;
>
> You limited the type to check the ones/zeroes of the input value, `count_leading_zeros_int(~ti->_bits._zeros), count_leading_zeros_int(ti->_bits._ones),`. I think we need test cases to cover those too, given they are more complex and thus more error prone.
I have no idea how the `KnownBits` works. I tried masking `i` with `i & 0x00ffffff | 0x0000ffff`, and evaluating CLZ on it. But C2 still seems to return an integer type with a trivial `KnownBits`, instead of `KnownBits` with `_zeros=0xff000000` and `_ones=0x0000ffff`.
I also checked the PR which introduced `KnownBits` (https://github.com/openjdk/jdk/pull/17508). @merykitty said "there is no node taking advantage of the additional information yet", and there's no IR tests about it. So it's probably impossible to write a test for this at the moment?
@merykitty Could you provide more help on this please? Thanks.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25928#discussion_r2163478028
More information about the hotspot-compiler-dev
mailing list