RFR: 8340454: C2 EA asserts with "previous reducible Phi is no longer reducible before SUT" [v2]

Cesar Soares Lucas cslucas at openjdk.org
Thu Oct 31 15:57:46 UTC 2024


> Please, consider this patch to fix an issue that happens when a Phi previously considered reducible become later irreducible. The overall situation that causes the problem is like so:
> 
> - Consider that there are at least 2 scalar replaceable objects (Obj1 and Obj2; Obj2 is stored in a field of Obj1) when we start iterating the loop at escape.cpp:301
> 
> - In the first iteration of the loop the call chain starting with `adjust_scalar_replaceable_state` ends up calling `can_reduce_phi` and considering Phi1 as reducible. This Phi has only Obj1 as *SR* input.
> 
> - In another iteration of the loop Obj2 is flagged as NSR. For instance, because we are storing Obj2 in an unknown position of an array. This will cause `found_nsr_alloc` to be set to `true`.
> 
> After the loop finishes, the execution will go to `find_scalar_replaceable_allocs`. The code will process Obj1, because it's still scalar replaceable, but will find that this object is stored in a field of a - **now** - NSR object. Therefore, correctly, Obj1 will also be marked as NSR. When Obj1 is marked as NSR Phi1 becomes irreducible because it doesn't have any more scalar replaceable input.
> 
> The solution I'm proposing is simply revisit the "reducibility" of the Phis when an object is marked as NSR.
> 
> ---------
> 
> ### Tests
> 
> Win, Mac & Linux tier1-4 on x64 & Aarch64.

Cesar Soares Lucas has updated the pull request incrementally with one additional commit since the last revision:

  Update test/hotspot/jtreg/compiler/escapeAnalysis/TestReduceAllocationAndNonReduciblePhi.java
  
  Co-authored-by: Tobias Hartmann <tobias.hartmann at oracle.com>

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/21778/files
  - new: https://git.openjdk.org/jdk/pull/21778/files/0361f272..d549e0de

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=21778&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21778&range=00-01

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/21778.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21778/head:pull/21778

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


More information about the hotspot-compiler-dev mailing list