<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Duplicate case blocks in switch can be merged" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24220&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=6UVZsW_TXuMaizjP-c6kvFmgmF_5u9Uh5LuMuE6H_rY&s=stb5KiiHIwKwBolxWHVhVX9BRPTwSkxEBKdCQU3TF5M&e=">24220</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Duplicate case blocks in switch can be merged
          </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>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </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>listmail@philipreames.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In the following example, many of the case blocks of the switch are identical
and could be merged into a single basic block.  This transformation should
likely live inside SimplifyCFG.  

declare void @foo()
declare void @bar()

define void @test(i16 %val1, i32 %local_2_) {
bci_84:                                           ; preds = %normal_return12
  switch i16 %val1, label %bci_149 [
    i16 45, label %bci_90
    i16 43, label %bci_103
    i16 58, label %bci_116
    i16 95, label %bci_129
    i16 46, label %bci_142
  ]

bci_149:
  call void @foo()
  ret void

bci_158:
  call void @bar()
  ret void

bci_142:                                          ; preds = %bci_84
  %.old = icmp eq i32 %local_2_, 0
  br i1 %.old, label %bci_149, label %bci_158

bci_129:                                          ; preds = %bci_84
  %_20 = icmp eq i32 %local_2_, 0
  br i1 %_20, label %bci_149, label %bci_158

bci_116:                                          ; preds = %bci_84
  %_21 = icmp eq i32 %local_2_, 0
  br i1 %_21, label %bci_149, label %bci_158

bci_103:                                          ; preds = %bci_84
  %_22 = icmp eq i32 %local_2_, 0
  br i1 %_22, label %bci_149, label %bci_158

bci_90:                                           ; preds = %bci_84
  %_23 = icmp eq i32 %local_2_, 0
  br i1 %_23, label %bci_149, label %bci_158
}</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>