JDK-8287840 : Dead copy region node blocks IfNode's fold-compares
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • CPU: generic
  • Submitted: 2022-06-06
  • Updated: 2024-06-03
  • Resolved: 2022-06-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19
19 b26Fixed
Related Reports
Relates :  
Description
IfNode::fold_compares() requires ctrl has single output. I found a fold-compares case is postpone until IterGVN2.  The reason is that a dead region prevents IfNode::fold_compares() from transforming code. 


here is an example.  At beginning of IterGVN,  the control of 205 If is 194 Region. 
```
 205  If  ===  194  204  [[ 206  207 ]] P=1.000000, C=6784.000000  Type:{0:control, 1:control} !jvms: java.time.temporal.ChronoField::isDateBased @ bci:23 (line 687) java.time.chrono.ChronoLocalDate::isSupported @ bci:8 (line 388)
 194  Region  === _  150  [[ 205 ]]   Type:control !jvms: java.time.temporal.ChronoField::isDateBased @ bci:20 (line 687) java.time.chrono.ChronoLocalDate::isSupported @ bci:8 (line 388)
```

IfNode::Ideal() calls Node::remove_dead_region() for 205. it simplified code a little bit. IfNode's control changes from 194 to 150. 

```
 150  IfFalse  ===  148  [[ 194  205 ]] #0  Type:control !jvms: java.time.temporal.ChronoField::isDateBased @ bci:10 (line 687) java.time.chrono.ChronoLocalDate::isSupported @ bci:8 (line 388)
 205  If  ===  150  204  [[ 206  207 ]] P=1.000000, C=6784.000000  Type:{0:control, 1:control} !jvms: java.time.temporal.ChronoField::isDateBased @ bci:23 (line 687) java.time.chrono.ChronoLocalDate::isSupported @ bci:8 (line 388)
 194  Region  === _  150  [[]]   Type:control !jvms: java.time.temporal.ChronoField::isDateBased @ bci:20 (line 687) java.time.chrono.ChronoLocalDate::isSupported @ bci:8 (line 388)
```

Even 194 Region is dead, but igvn can't remove it in time. This code shape still miss IfNode::fold_compares() because 150's output isn't single.

    if (is_ctrl_folds(ctrl, igvn) && ctrl->outcnt() == 1) {}

Comments
Changeset: 3da7e393 Author: Xin Liu <xliu@openjdk.org> Date: 2022-06-07 17:12:14 +0000 URL: https://git.openjdk.java.net/jdk/commit/3da7e393ee4b45c40b8bb132dd09f5a6ba306116
07-06-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/9035 Date: 2022-06-06 01:15:35 +0000
06-06-2022