JDK-8079343 : Crash in PhaseIdealLoop with "assert(!had_error) failed: bad dominance"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-05-05
  • Updated: 2017-08-07
  • Resolved: 2015-05-11
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 8 JDK 9
8u60Fixed 9 b66Fixed
Related Reports
Blocks :  
Description
While running the regression test "TestVectorizationWithInvariant.java" for JDK-8078497 with a clean JDK9 build I found the following problem:

Bad graph detected in compute_lca_of_uses
n:  639	Bool	=== _  640  [[ 670 ]] [lt] !orig=480,[174] !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:22
early(n):  745	CountedLoop	===  745  688  176  [[ 745  849  751  750  848  744  481 ]] inner stride: 16 main of N745 !orig=[482],[441],[374] !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:43
n->in(1):  640	CmpI	=== _  641  845  [[ 639 ]]  !orig=479,[173] !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:22
early(n->in(1)):  745	CountedLoop	===  745  688  176  [[ 745  849  751  750  848  744  481 ]] inner stride: 16 main of N745 !orig=[482],[441],[374] !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:43
n->in(1)->in(1):  641	AddI	=== _  674  267  [[ 638  640  674  680  685  690 ]]  !orig=397,268 !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:131
early(n->in(1)->in(1)):  669	CountedLoop	===  669  539  671  [[ 618  624  630  636  644  650  651  656  668  669  670  674  675 ]] inner stride: 8 pre of N482 !orig=[482],[441],[374] !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:43
n->in(1)->in(2):  845	MinI	=== _  172  844  [[ 640 ]]  !orig=[692]
early(n->in(1)->in(2)):  745	CountedLoop	===  745  688  176  [[ 745  849  751  750  848  744  481 ]] inner stride: 16 main of N745 !orig=[482],[441],[374] !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:43

LCA(n):  669	CountedLoop	===  669  539  671  [[ 618  624  630  636  644  650  651  656  668  669  670  674  675 ]] inner stride: 8 pre of N482 !orig=[482],[441],[374] !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:43
n->out(0):  670	CountedLoopEnd	===  669  639  [[ 671  683 ]] [lt] P=0.900000, C=-1.000000 !orig=481,[175] !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:22
n->out(0)->out(0):  671	IfTrue	===  670  [[ 669 ]] #1 !orig=176 !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:22
n->out(0)->out(1):  683	IfFalse	===  670  [[ 687 ]] #0

idom[0]  669	CountedLoop	===  669  539  671  [[ 618  624  630  636  644  650  651  656  668  669  670  674  675 ]] inner stride: 8 pre of N482 !orig=[482],[441],[374] !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:43
idom[1]  539	IfTrue	===  538  [[ 669 ]] #1 !orig=176 !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:22
idom[2]  538	CountedLoopEnd	===  534  507  [[ 539  546 ]] [lt] P=0.900000, C=-1.000000 !orig=481,[175] !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:22
idom[3]  534	IfTrue	===  532  [[ 483  487  489  493  495  499  501  505  510  514  516  517  518  519  521  523  533  538  648  430  652  846  741  847  654  657  665  555  561  567  575  581  585  587  590  598  622  628  634  642 ]] #1 !orig=[426],198 !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:43
idom[4]  532	If	===  424  194  [[ 534  544 ]] P=0.999999, C=-1.000000 !orig=[425],197 !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:43
idom[5]  424	IfTrue	===  423  [[ 532 ]] #1 !orig=176 !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:22
idom[6]  423	If	===  106  421  [[ 424  442 ]] P=0.900000, C=-1.000000 !orig=[175] !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:22
idom[7]  106	Region	===  106  369  111  [[ 106  107  423 ]]  !orig=[150],[163] !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:18
idom[8]  110	If	===  89  109  [[ 111  112 ]] P=0.999000, C=-1.000000 !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:18
idom[9]  89	Region	===  89  365  94  [[ 89  90  110 ]]  !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:18
idom[10]  93	If	===  71  92  [[ 94  95 ]] P=0.999000, C=-1.000000 !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:18
idom[11]  71	Region	===  71  361  76  [[ 71  72  93 ]]  !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:18
idom[12]  75	If	===  53  74  [[ 76  77 ]] P=0.999000, C=-1.000000 !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:18
idom[13]  53	Region	===  53  357  59  [[ 53  54  75 ]]  !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:18
idom[14]  58	If	===  46  57  [[ 59  60 ]] P=0.999000, C=-1.000000 !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:18
idom[15]  46	Proj	===  45  [[ 58 ]] #0 !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:18
idom[16]  45	CallLeaf	===  5  1  7  8  1 ( 10 ) [[ 46  48 ]] # OSR_migration_end void ( rawptr:BotPTR ) !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:18
idom[17]  5	Parm	===  3  [[ 44  45  25  29  33  37  41 ]] Control !jvms: TestVectorizationWithInvariant::copyByteToChar @ bci:18

*** Use 669 isn't dominated by def 639 ***
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=/loopnode.cpp:3231
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/oracle/full_jdk/hotspot/src/share/vm/opto/loopnode.cpp:3231), pid=14752, tid=0x00007fd0082fd700
#  assert(!had_error) failed: bad dominance


To reproduce simply run:
java -Xcomp TestVectorizationWithInvariant

Comments
Fix verified by regression test.
07-08-2017

The failing test looks like this: byte[] src = src1; for (int i = ...) { // Copy 8 chars from src to dst ... // Prevent loop invariant code motion of char read. src = (src == src1) ? src2 : src1; } The problem is that the superword optimization tries to vectorize the 8 load char / store char operations in the loop. In 'SuperWord::align_initial_loop_index' the base address of the memory operation we align the loop to 'align_to_ref_p.base()' is not loop invariant because 'src' changes in each iteration. However, we use it's value to correctly align the address if 'vw > ObjectAlignmentInBytes' (see line 2344). This is wrong because the address changes in each iteration. It also causes follow up problems in 'PhaseIdealLoop::verify_dominance' because nodes in the pre-loop have a control in the main-loop.
08-05-2015

ILW = crash, simple reproducer available, workaround exists (-XX:-UseSuperWord) = HHL = P2
05-05-2015