<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 - Instcombine does not work after 'and'/'or' were replaced with 'select'"
   href="https://bugs.llvm.org/show_bug.cgi?id=52077">52077</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Instcombine does not work after 'and'/'or' were replaced with 'select'
          </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>Windows NT
          </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>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=25330" name="attach_25330" title="The file demonstrates a missing optimization in instcombine">attachment 25330</a> <a href="attachment.cgi?id=25330&action=edit" title="The file demonstrates a missing optimization in instcombine">[details]</a></span>
The file demonstrates a missing optimization in instcombine

The code bellow is being optimized by instcombine if we put and/or instead of
'select':
lor.lhs.false:                                    ; preds = %for.body6
  %or.cond87.not = xor i1 %or.cond, true

  ;%or.cond88 = or i1 %or.cond87.not, %cmp16
  %or.cond88 = select i1 %or.cond87.not, i1 true, i1 %cmp16

  %or.cond88.not = xor i1 %or.cond88, true

  ;%or.cond89 = and i1 %or.cond88.not, %cmp28
  %or.cond89 = select i1 %or.cond88.not, i1 %cmp28, i1 false

  %or.cond89.not = xor i1 %or.cond89, true

  ;%or.cond92 = or i1 %or.cond88, %cmp28
  %or.cond92 = select i1 %or.cond88, i1 true, i1 %cmp28

  ;%or.cond93 = and i1 %or.cond89.not, %or.cond92
  %or.cond93 = select i1 %or.cond89.not, i1 %or.cond92, i1 false

There are also some changes were done in visitSelectInst()
if (match(TrueVal, m_One()) && impliesPoison(FalseVal, CondVal)) {
      // Change: A = select B, true, C --> A = or B, C
      return BinaryOperator::CreateOr(CondVal, FalseVal);
}
IsSafeToConvert() was replaced with impliesPoison()</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>