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

Bug in C1 ControlFlowOptimizer::delete_unnecessary_jumps with bytecode profiling

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • hotspot
    • None
    • b96
    • generic
    • generic

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

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

              Created:
              Updated:
              Resolved: