RFR: 8349032: C2: Parse Predicate refactoring in Loop Unswitching broke fix for JDK-8290850

Christian Hagedorn chagedorn at openjdk.org
Thu Feb 20 12:23:37 UTC 2025


In the refactoring for [JDK-8344035](https://bugs.openjdk.org/browse/JDK-8344035), the value passed for the `rewire_uncommon_proj_phi_inputs` parameter in `PhaseIdealLoop::create_new_if_for_predicate()` during Loop Unswitching was accidentally flipped. It should only be set to `true` when calling it for a false-path loop, which is the cloned loop. This is currently not the case and leads to a bad graph due to folding nodes wrongly:
https://github.com/openjdk/jdk/blob/735805d9259037ae594eb4f75e96860d43feea5d/src/hotspot/share/opto/predicates.cpp#L84-L88

I fixed this by just flipping the parameter from `is_true_path_loop` to `is_false_path_loop` to avoid a negation. I added an additional comment to `PhaseIdealLoop::create_new_if_for_predicate()` about `rewire_uncommon_proj_phi_inputs`.

More background about why we need `rewire_uncommon_proj_phi_inputs` in the first place can be found in the corresponding fix for [JDK-8290850](https://bugs.openjdk.org/browse/JDK-8290850): https://github.com/openjdk/jdk/pull/11452, and additionally in https://github.com/openjdk/jdk/pull/5185

Thanks,
Christian

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

Commit messages:
 - 8349032: C2: Parse Predicate refactoring in Loop Unswitching broke fix for JDK-8290850

Changes: https://git.openjdk.org/jdk/pull/23712/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23712&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8349032
  Stats: 88 lines in 5 files changed: 70 ins; 0 del; 18 mod
  Patch: https://git.openjdk.org/jdk/pull/23712.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23712/head:pull/23712

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


More information about the hotspot-compiler-dev mailing list