<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 - Loop unswitching stopped happening"
   href="https://bugs.llvm.org/show_bug.cgi?id=34257">34257</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Loop unswitching stopped happening
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </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>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>aivchenk@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>foo.cpp:                                                                        
int foo(bool x, int a) {
  int s = a;
  int i = 0;
  while (i < 10000) {
    int y = x ? a : i;
    s += y;
    i++;
  }
  return s;
}
<span class="quote">>clang++ foo.cpp -c -S -emit-llvm -o llvm_version.ll -O3</span >

Before <a href="https://reviews.llvm.org/D35811">https://reviews.llvm.org/D35811</a> we used to nicely unswitch this loop:

define i32 @_Z12llvm_versionbi(i1 zeroext %x, i32 %a) local_unnamed_addr #0 {   
entry:                                                                          
  %0 = mul i32 %a, 10001                                                        
  %1 = add i32 %a, 49995000                                                     
  %s.0.lcssa = select i1 %x, i32 %0, i32 %1                                     
  ret i32 %s.0.lcssa                                                            
}

I guess that degradation is expected, though, but, I'm not 100% sure</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>