RFR: 8349361: C2: RShiftL should support all applicable transformations that RShiftI does [v9]

Roland Westrelin roland at openjdk.org
Tue Feb 25 12:28:57 UTC 2025


On Mon, 24 Feb 2025 15:45:58 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Roland Westrelin 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 15 additional commits since the last revision:
>> 
>>  - review
>>  - review
>>  - review
>>  - Merge branch 'master' into JDK-8349361
>>  - Update src/hotspot/share/opto/mulnode.cpp
>>    
>>    Co-authored-by: Emanuel Peter <emanuel.peter at oracle.com>
>>  - Update src/hotspot/share/opto/mulnode.cpp
>>    
>>    Co-authored-by: Emanuel Peter <emanuel.peter at oracle.com>
>>  - review
>>  - Update src/hotspot/share/opto/mulnode.hpp
>>    
>>    Co-authored-by: Jasmine Karthikeyan <25208576+jaskarth at users.noreply.github.com>
>>  - Update src/hotspot/share/opto/mulnode.cpp
>>    
>>    Co-authored-by: Jasmine Karthikeyan <25208576+jaskarth at users.noreply.github.com>
>>  - Update src/hotspot/share/opto/mulnode.cpp
>>    
>>    Co-authored-by: Jasmine Karthikeyan <25208576+jaskarth at users.noreply.github.com>
>>  - ... and 5 more: https://git.openjdk.org/jdk/compare/81c4d62f...5b05d222
>
> test/hotspot/jtreg/compiler/c2/irTests/RShiftLNodeIdealizationTests.java line 145:
> 
>> 143:     public long test9(long x) {
>> 144:         x = Integer.max(Integer.min((int)x, (int)test7Max), (int)(test7Min-1));
>> 145:         return ((x << test7Shift) >> test7Shift);
> 
> It could be nice to have some test cases where both shift values are completely randomized.

The transformation only happens if the amounts we shift left and right are the same. So if they are random, the transformation won't apply most of the time and, rarely, it will (because they will turn out to be the same). I'm not sure how to write an IR test then.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23438#discussion_r1969662561


More information about the hotspot-compiler-dev mailing list