JDK-8332905 : C2 SuperWord: bad AD file, with RotateRightV and first operand not a pack
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 16,17,21,23
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-05-24
  • Updated: 2024-06-07
  • Resolved: 2024-06-04
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 23
23 b26Fixed
Related Reports
Relates :  
Description
I just discovered this bug by manual code inspection, and found a reproducer.

It seems to be a regression of JDK-8248830, that is when RotateRightV was added to SuperWord.

The problem is that we directly get the input node, rather than the vector_opd, which fails if that input is not a vector already, but for example a PopulateIndex pattern that is only vectorized when calling vector_opd.

[~jbhateja] did this:

      } else if (VectorNode::is_scalar_rotate(n)) {
        Node* in1 = low_adr->in(1);
        Node* in2 = p->at(0)->in(2);

And by now it looks like this:

      } else if (VectorNode::is_scalar_rotate(n)) {
        Node* in1 = first->in(1);
        Node* in2 = first->in(2);

But at least in1 should be using vector_opd, like most other ops:

        Node* in1 = vector_opd(p, 1);

When the input is a PopulateIndex pattern, then "first->in(1)" gives us the iv-phi, which is a scalar. vector_opd would produce a PopulateIndex vector.

In the ad-file, we get an error, because we do not expect a scalar as the first operand of the RotateRightV, but a vector.

Reproduces on JDK23, JDK22, JDK21, maybe older.

/oracle-work/jdk-fork4/build/linux-x64-debug/jdk/bin/java -XX:CompileCommand=compileonly,TestRotate::* -Xbatch TestRotate.java

/oracle-work/jdk-21.0.3/fastdebug/bin/java -XX:CompileCommand=compileonly,TestRotate::* -Xbatch -XX:+UseSuperWord TestRotate.java

Disabling -XX:-UseSuperWord avoids the crash.

Strangely, product seems to run just fine.
But I'm not sure I'd trust the result... though it seems to be correct in the reproducer.

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

sum: -1220673536
sum: -1220673536
sum: -1220673536
sum: -1220673536
sum: -1220673536
sum: -1220673536
sum: -1220673536
sum: -1220673536
sum: -1220673536
sum: -1220673536
o895  RotateRightV  === _ o977 o137  [[ o896 ]]  #vectorz[16]:{int}

--N: o895  RotateRightV  === _ o977 o137  [[ o896 ]]  #vectorz[16]:{int}

   --N: o977  AddI  === _ o1176 o1198  [[ o895 ]] 
   RREGI  110  addI_rReg_imm
   RAX_REGI  110  addI_rReg_imm
   RBX_REGI  110  addI_rReg_imm
   RCX_REGI  110  addI_rReg_imm
   RDX_REGI  110  addI_rReg_imm
   RDI_REGI  110  addI_rReg_imm
   NO_RAX_RDX_REGI  110  addI_rReg_imm
   NO_RBP_R13_REGI  110  addI_rReg_imm
   STACKSLOTI  210  storeSSI
   _AddI_rRegI_rRegI  100  _AddI_rRegI_rRegI

      --N: o1176  Phi  === o1172 o1247 o242  [[ o1159 o1160 o1161 o1162 o1163 o1164 o242 o1058 o1057 o977 ]]  #int #tripcount
      RREGI  0  RREGI
      RAX_REGI  0  RAX_REGI
      RBX_REGI  0  RBX_REGI
      RCX_REGI  0  RCX_REGI
      RDX_REGI  0  RDX_REGI
      RDI_REGI  0  RDI_REGI
      NO_RAX_RDX_REGI  0  NO_RAX_RDX_REGI
      NO_RBP_R13_REGI  0  NO_RBP_R13_REGI
      STACKSLOTI  100  storeSSI

      --N: o1198  ConI  === o0  [[ o977 ]]  #int:112
      IMMI  10  IMMI
      IMMU7  5  IMMU7
      IMMI8  5  IMMI8
      IMMU8  5  IMMU8
      IMMI16  10  IMMI16
      IMMU31  0  IMMU31
      RREGI  100  loadConI
      RAX_REGI  100  loadConI
      RBX_REGI  100  loadConI
      RCX_REGI  100  loadConI
      RDX_REGI  100  loadConI
      RDI_REGI  100  loadConI
      NO_RAX_RDX_REGI  100  loadConI
      NO_RBP_R13_REGI  100  loadConI
      STACKSLOTI  200  storeSSI

   --N: o137  ConI  === o0  [[ o895 o262 o302 o906 o976 o1055 o1056 o1156 o1157 o1158 o1159 ]]  #int:18
   IMMI  10  IMMI
   IMMU7  5  IMMU7
   IMMI8  5  IMMI8
   IMMU8  5  IMMU8
   IMMI16  10  IMMI16
   IMMU31  0  IMMU31
   RREGI  100  loadConI
   RAX_REGI  100  loadConI
   RBX_REGI  100  loadConI
   RCX_REGI  100  loadConI
   RDX_REGI  100  loadConI
   RDI_REGI  100  loadConI
   NO_RAX_RDX_REGI  100  loadConI
   NO_RBP_R13_REGI  100  loadConI
   STACKSLOTI  200  storeSSI

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/oracle-work/jdk-fork4/open/src/hotspot/share/opto/matcher.cpp:1727), pid=2026916, tid=2026930
#  assert(false) failed: bad AD file
#
# JRE version: Java(TM) SE Runtime Environment (23.0) (fastdebug build 23-internal-2024-05-22-1054280.emanuel...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 23-internal-2024-05-22-1054280.emanuel..., mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x134c5da]  Matcher::Label_Root(Node const*, State*, Node*, Node*&)+0x87a
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /oracle-work/jdk-fork2/build/linux-x64-debug/jdk/bin/core.2026916)
#
# An error report file with more information is saved as:
# /oracle-work/jdk-fork2/build/linux-x64-debug/jdk/bin/hs_err_pid2026916.log
#
# Compiler replay data is saved as:
# /oracle-work/jdk-fork2/build/linux-x64-debug/jdk/bin/replay_pid2026916.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#
Aborted (core dumped)
Comments
Changeset: 67d6f3ca Author: Emanuel Peter <epeter@openjdk.org> Date: 2024-06-04 06:20:31 +0000 URL: https://git.openjdk.org/jdk/commit/67d6f3ca9e8d1312c9e3a85dbe19903619f59064
04-06-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/19445 Date: 2024-05-29 07:20:33 +0000
29-05-2024

Targeting to JDK 24 for now since it's an old issue. Feel free to re-target to JDK 23 if the fix is ready in time.
27-05-2024

ILW = Assert during C2 compilation due to unexpected RotateRightV operand, never observed but reproducible with targeted regression test, disable SuperWord or compilation of affected method = HLM = P3
27-05-2024