gunter.haug@sap.com reported the following bug:
Bug in C1 ControlFlowOptimizer::delete_unnecessary_jumps with bytecode profiling
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 ...
Bug in C1 ControlFlowOptimizer::delete_unnecessary_jumps with bytecode profiling
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 ...
- relates to
-
JDK-8143930 C1 LinearScan asserts when compiling two back-to-back CompareAndSwapLongs
-
- Closed
-