RFR(S): 8142314: Bug in C1 ControlFlowOptimizer::delete_unnecessary_jumps with bytecode profiling

Volker Simonis volker.simonis at gmail.com
Mon Nov 9 14:11:20 UTC 2015


Hi,

can I please have a review and a sponsor for the following change
contributed by gunter.haug at sap.com:

http://cr.openjdk.java.net/~simonis/webrevs/2015/8142314/
https://bugs.openjdk.java.net/browse/JDK-8142314

The function ControlFlowOptimizer::delete_unnecessary_jumps reorders
basic block to minimize the number of branches required.
For example, it transforms

B1 ...
  cmp [NE] [R1|I] [int:0|I]
  branch [NE] [B1]
  branch [AL] [B2]
B1 ...
B2 ...

to

B1 ...
  cmp [EQ] [R1|I] [int:0|I]
  branch [EQ] [B2]
B1 ...
B2 ...

Bytecode profiling generates a pattern like this:

B1 ...
  cmp [NE] [R1|I] [int:0|I]
  cmov [NE] [B1_counter] [B2_counter] [R2]
  ...
  branch [NE] [B1]
  branch [AL] [B2]
B1 ...
B2 ...

ControlFlowOptimizer::delete_unnecessary_jumps doesn't take care of
the cmov. So the code above will transform to

B1 ...
  cmp [EQ] [R1|I] [int:0|I]
  cmov [NE] [B1_counter] [B2_counter] [R2]
  ...
  branch [EQ] [B2]
B1 ...
B2 ...

On most platforms this does no harm as the cmp of the instruction
doesn't depend on the condition. However, on Itanium the the cmp
depends on the condition. Therefore the correct code should be:

B1 ...
  cmp [EQ] [R1|I] [int:0|I]
  cmov [EQ] [B2_counter] [B1_counter] [R2]
  ...
  branch [EQ] [B2]
B1 ...
B2 ...


Thank you and best regards,
Volker


More information about the hotspot-compiler-dev mailing list