RFR: 8347459: C2: missing transformation for chain of shifts/multiplications by constants [v4]
Damon Fenacci
dfenacci at openjdk.org
Thu Feb 27 11:55:03 UTC 2025
On Thu, 27 Feb 2025 08:33:44 GMT, Marc Chevalier <duke at openjdk.org> wrote:
>> test/hotspot/jtreg/compiler/c2/irTests/LShiftINodeIdealizationTests.java line 255:
>>
>>> 253: res[0] = (short) (a[0] << 3);
>>> 254: return res;
>>> 255: }
>>
>> In the comment of method `StoreNode::Ideal_sign_extended_input` you mention shifting left by more than 24. Do you think it would be possible to have a test for that case too (shifting left by more than 16 in this case I guess)?
>
> I'm talking about is the case where the shift exceed 24, but taking into account the double shifting used to sign-extend the value. In the case of this test, we would get a `((a[0] << 3) << 16) >> 16` that my improvement will change into `(a[0] << 19) >> 16`which used not to be supported. The 19 here is the shift larger than 16.
>
> But I think you meant replacing the `3` in the test with something like `17`. Then, the expression will look like `((a[0] << 17) << 16) >> 16` that my change collapses into `0 >> 16`, since 16 + 17 = 33 is bigger than the length of an int. (It is tested by one of the previous cases in the same file). So nothing really exciting happens there.
>
> Or maybe you're suggesting something else I've missed?
All good, I think I simply misunderstood the comment. The case is actually the one where the shift is more than 24. Thanks for the explanation!
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23728#discussion_r1973430094
More information about the hotspot-compiler-dev
mailing list