<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Missing identical block merging"
   href="https://bugs.llvm.org/show_bug.cgi?id=33583">33583</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missing identical block merging
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>davide@freebsd.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>filcab@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, simon.f.whittaker@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>LLVM lowers the following (with -O3 -fno-vectorize -c)

extern void f4();

void function(int x) {
   if (x == 0) f4();
   else if (x == 1) f4();
   else if (x == 2) f4();
   else if (x == 3) f4();
   else if (x == 4) f4();
   else if (x == 5) f4();
   else if (x == 6) f4();
}

into a switch, but duplicates the destination block n times, 
i.e.

  switch i32 %0, label %9 [
    i32 0, label %2
    i32 1, label %3
    i32 2, label %4
    i32 3, label %5
    i32 4, label %6
    i32 5, label %7
    i32 6, label %8
  ]

; <label>:2:                                      ; preds = %1
  tail call void @f4()()
  br label %9

; <label>:3:                                      ; preds = %1
  tail call void @f4()()
  br label %9

; <label>:4:                                      ; preds = %1
  tail call void @f4()()
  br label %9

; <label>:5:                                      ; preds = %1
  tail call void @f4()()
  br label %9

; <label>:6:                                      ; preds = %1
  tail call void @f4()()
  br label %9

; <label>:7:                                      ; preds = %1
  tail call void @f4()()
  br label %9

We manage to recognize identical blocks in the backend and merge them,


but it seems we could do it already in the middle-end.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>