This is a reopen of JDK-8192992 whose fix was found insufficient.
The problem is that a testN_mem_reg is matched but the load matching the mem to the test is far away from the jump and need to be spilled but can't be.
The first fix of JDK-8192992 with the follow ups JDK-8204157 and JDK-8205999 focused on the fact that the load was placed higher up than required. The scheduling in insert_anti_dependences is conservative for all phi and forces the LCA up.
A proper fix need to search through phi nodes, like we do we mergemens, and hoisting the load only if a successor store is found. For loops, a store in the loop should force the load up above the phi, like currently.
Fixing insert_anti_dependences is a full enhancements of its own. Possible quick fixes for this bug:
1) Disable testN_mem_reg0 (only compressed oops with heapbase 0).
Possibly and add a peephole rule that can match this instruction when the load-test and jmp are in the same block.
2) Add some scheduling check to testN_mem_reg0 - the load-test and jmp need to be in the same block.