<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 - Unswitching does not catch opportunity with -fexperimental-new-pass-manager"
   href="https://bugs.llvm.org/show_bug.cgi?id=34313">34313</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unswitching does not catch opportunity with -fexperimental-new-pass-manager
          </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>Loop Optimizer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>chandlerc@gmail.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>stefanp@ca.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>With the following test code:

int has_utf8 = 1;
const char AA[] = {
  0, 1, 2, 3, 156, 9, 134, 17
};

int main() {
  long i, count=0, num=22;
  for (i=0; i<100000000; i++) {
    num = i % 7;
    if (!has_utf8 && AA[num] < 0x4)
      count+=AA[num+1];
  }
  return count;
}

we can move the "if (!has_utf8)" outside of the loop and not run the loop at
all when has_utf8 = 1. 
The opportunity is caught correctly with the old pass manager but not with the
new one. 
Found with these options:
-m64 -mcpu=power8 -O3
Not found with these ones:
-m64 -mcpu=power8 -O3 -fexperimental-new-pass-manager

I did try the new unswitching pass from this patch:
<a href="https://reviews.llvm.org/D34200">https://reviews.llvm.org/D34200</a>
but the compiler still did not find the opportunity.</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>