RFR: 8356708: C2: loop strip mining expansion doesn't take sunk stores into account [v5]

Roland Westrelin roland at openjdk.org
Tue Jun 17 08:15:15 UTC 2025


> `test1()` has a counted loop with a `Store` to `field`. That `Store`
> is sunk out of loop. When the `OuterStripMinedLoop` is expanded, only
> `Phi`s that exist at the inner loop are added to the outer
> loop. There's no `Phi` for the slice of the sunk `Store` (because
> there's no `Store` left in the inner loop) so no `Phi` is added for
> that slice to the outer loop. As a result, there's a missing anti
> dependency for `Load` of `field` that's before the loop and it can be
> scheduled inside the outer strip mined loop which is incorrect.
> 
> `test2()` is the same as `test1()` but with a chain of 2 `Store`s.
> 
> `test3()` is another variant where a `Store` is left in the inner loop
> after one is sunk out of it so the inner loop still has a `Phi`. As a
> result, the outer loop also gets a `Phi` but it's incorrectly wired as
> the sunk `Store` should be the input along the backedge but is
> not. That one doesn't cause any failure AFAICT.
> 
> The fix I propose is some extra logic at expansion of the
> `OuterStripMinedLoop` to handle these corner cases.

Roland Westrelin has updated the pull request incrementally with four additional commits since the last revision:

 - Update src/hotspot/share/opto/loopnode.cpp
   
   Co-authored-by: Emanuel Peter <emanuel.peter at oracle.com>
 - Update src/hotspot/share/opto/loopnode.cpp
   
   Co-authored-by: Emanuel Peter <emanuel.peter at oracle.com>
 - Update src/hotspot/share/opto/loopnode.cpp
   
   Co-authored-by: Emanuel Peter <emanuel.peter at oracle.com>
 - Update src/hotspot/share/opto/loopnode.cpp
   
   Co-authored-by: Emanuel Peter <emanuel.peter at oracle.com>

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/25717/files
  - new: https://git.openjdk.org/jdk/pull/25717/files/ae62f7d3..e7289215

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=25717&range=04
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=25717&range=03-04

  Stats: 8 lines in 1 file changed: 2 ins; 1 del; 5 mod
  Patch: https://git.openjdk.org/jdk/pull/25717.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25717/head:pull/25717

PR: https://git.openjdk.org/jdk/pull/25717


More information about the hotspot-compiler-dev mailing list