RFR: 8356176: C2 MemorySegment: missing RCE with byteSize() in Loop Exit Check inside the for Expression [v2]
Manuel Hässig
mhaessig at openjdk.org
Mon Aug 11 15:32:41 UTC 2025
On Mon, 11 Aug 2025 01:11:09 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Manuel Hässig has updated the pull request incrementally with three additional commits since the last revision:
>>
>> - Fix debug print
>> - Test more flags
>> - Renaming and comments
>
> src/hotspot/share/opto/loopnode.hpp line 1645:
>
>> 1643: _total_wins(0),
>> 1644: _loop_entry_wins(0),
>> 1645: _loop_back_wins(0) {};
>
> Can you describe somewhere what the definition of these is?
> I'm struggling a little with understanding the conditions in `profitable`.
I hope it is better now.
> src/hotspot/share/opto/loopopts.cpp line 239:
>
>> 237: } else {
>> 238: tty->print("Region ");
>> 239: }
>
> What if it is another kind of loop? Could it be a `LongCountedLoop` or something else we don't have yet?
> I suggest you just use `region->Name()` and format that string into your output.
I did not know about that.
> test/hotspot/jtreg/compiler/loopopts/InvariantCodeMotionReassociateAddSub.java line 351:
>
>> 349: @IR(counts = {IRNode.SUB_I, "1"})
>> 350: public int addSubInt(int inv1, int inv2, int size) {
>> 351: int result = -1;
>
> Can you document where the adds are?
> Do we manage to re-assoriate `inv1 + (inv2 - i)` to `(inv1 + inv2) - i` so that the addition can float out of the loop?
Yes, the addition floats, and the loop disappears.
> test/hotspot/jtreg/compiler/loopopts/superword/TestMemorySegmentByteSizeLongLoopLimit.java line 38:
>
>> 36: * @library /test/lib /
>> 37: * @run driver compiler.loopopts.superword.TestMemorySegmentByteSizeLongLoopLimit
>> 38: */
>
> For MemorySegment tests, I've made the experience that it is quite important to test out some runs with additional flag combinations: at least `AlignVector` and `ShortRunningLongLoop`. Same might apply for the tests below.
I added scenarios.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26429#discussion_r2267130654
PR Review Comment: https://git.openjdk.org/jdk/pull/26429#discussion_r2267133830
PR Review Comment: https://git.openjdk.org/jdk/pull/26429#discussion_r2267129512
PR Review Comment: https://git.openjdk.org/jdk/pull/26429#discussion_r2267130083
More information about the hotspot-compiler-dev
mailing list