Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8142314

Bug in C1 ControlFlowOptimizer::delete_unnecessary_jumps with bytecode profiling

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b96
    • CPU:
      generic
    • OS:
      generic

      Description

      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 ...

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                simonis Volker Simonis
                Reporter:
                simonis Volker Simonis
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: