<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 - SelectInst that replaces Or/And is not handled in SimplifyCFG"
   href="https://bugs.llvm.org/show_bug.cgi?id=52065">52065</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SelectInst that replaces Or/And is not handled in SimplifyCFG
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Miscellaneous Instrumentation passes
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>elena.demikhovsky@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=25323" name="attach_25323" title="Before simpilfycfg, demonstrates Select/Or/And missing optimization">attachment 25323</a> <a href="attachment.cgi?id=25323&action=edit" title="Before simpilfycfg, demonstrates Select/Or/And missing optimization">[details]</a></span>
Before simpilfycfg, demonstrates Select/Or/And missing optimization

The basic block with "or" is optimized in simplifycfg:

  lor.lhs.false30:                                  ; preds = %lor.lhs.false
   %or.cond92 = or i1 %or.cond88, %cmp28
   br i1 %or.cond92, label %if.end, label %if.then

while the same block with "select" is not optimized:

  lor.lhs.false30:                                  ; preds = %lor.lhs.false
    %or.cond92 = select i1 %or.cond88, i1 true, i1 %cmp28
    br i1 %or.cond92, label %if.end, label %if.then

This diff maybe considered as a fix:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp:

<   if (!Cond || (!isa<CmpInst>(Cond) && !isa<BinaryOperator>(Cond)) ||
---
<span class="quote">>   auto isSelectAsBinaryOperator = [](Instruction *V) {
>     return match(V, m_Select(m_Value(), m_Value(), m_Zero())) ||
>            match(V, m_Select(m_Value(), m_One(), m_Value()));
>   };
>   if (!Cond ||
>       (!isa<CmpInst>(Cond) && !isa<BinaryOperator>(Cond) &&
>        !isSelectAsBinaryOperator(Cond)) ||</span ></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>