RFR: 8301313: RISC-V: C2: assert(false) failed: bad AD file due to missing match rule

Feilong Jiang fjiang at openjdk.org
Mon Jan 30 14:51:08 UTC 2023


The RISC-V architecture does not support conditional move instructions or flags register for now. So we set `ConditionalMoveLimit` to 0 for this port to avoid the generation of the CMove node by C2. But turns out this could not avoid all CMove nodes generation: some CMove generations are not guarded by this parameter. Therefore, we still need to add match rules in AD file for CMove nodes like `CMoveI_CmpI`/`CMoveL_CmpL` etc. to cover those scenarios.

In this case, we observed that CMoveL was generated in `PhaseIdealLoop::transform_long_range_checks`,  which could match exactly with `cmoveL_cmpL` [1]:
https://github.com/openjdk/jdk/blob/ebb84ad70d3295d9a429904fcdacdb8ecd1bf434/src/hotspot/share/opto/loopnode.cpp#L1344-L1351

But `PhaseIdealLoop::optimize` after `PhaseIdealLoop::transform_long_range_checks` may replace CmpLNode with CmpINode in `CmpLNode::Ideal`:
https://github.com/openjdk/jdk/blob/ebb84ad70d3295d9a429904fcdacdb8ecd1bf434/src/hotspot/share/opto/subnode.cpp#L877-L886

In riscv.ad, there is no match rule for CMoveL and CmpI, which result in the bad AD file.

With this fix, we should be able to cover all other CMove scenarios not guarded by `ConditionalMoveLimit`.

1: https://github.com/openjdk/jdk/blob/ebb84ad70d3295d9a429904fcdacdb8ecd1bf434/src/hotspot/cpu/riscv/riscv.ad#L10046-L10061

Testing:

- [x] jdk_foreign  with -XX:-TieredCompilation (fastdebug)
- [x] Tier1~3 on Unmatched board (release)

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

Commit messages:
 - add missing match rules for CMoveL

Changes: https://git.openjdk.org/jdk/pull/12295/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12295&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8301313
  Stats: 37 lines in 1 file changed: 33 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/12295.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12295/head:pull/12295

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


More information about the hotspot-compiler-dev mailing list