<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: incorrect select operand simplification with undef"
   href="https://bugs.llvm.org/show_bug.cgi?id=47696">47696</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>InstCombine: incorrect select operand simplification with undef
          </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>Keywords</th>
          <td>miscompilation
          </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>nunoplopes@sapo.pt
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, nikita.ppv@gmail.com, regehr@cs.utah.edu, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Test: Transforms/InstCombine/select-binop-cmp.ll

Seems to be a regression from <a href="https://reviews.llvm.org/D87480">https://reviews.llvm.org/D87480</a>
The undef operand in the icmp needs to be fixed to 0 for the transformation to
be correct. See here: <a href="https://alive2.llvm.org/ce/z/YYhL33">https://alive2.llvm.org/ce/z/YYhL33</a>


define <2 x i8> @select_xor_icmp_vec_undef(<2 x i8> %x, <2 x i8> %y, <2 x i8>
%z) {
  %A = icmp eq <2 x i8> %x, { 0, undef }
  %B = xor <2 x i8> %x, %z
  %C = select <2 x i1> %A, <2 x i8> %B, <2 x i8> %y
  ret <2 x i8> %C
}
=>
define <2 x i8> @select_xor_icmp_vec_undef(<2 x i8> %x, <2 x i8> %y, <2 x i8>
%z) {
  %A = icmp eq <2 x i8> %x, { 0, undef }
  %C = select <2 x i1> %A, <2 x i8> %z, <2 x i8> %y
  ret <2 x i8> %C
}
Transformation doesn't verify!
ERROR: Target's return value is more undefined

Example:
<2 x i8> %x = < poison, #x01 (1) >
<2 x i8> %y = < poison, #x00 (0) >
<2 x i8> %z = < poison, #x01 (1) >

Source:
<2 x i1> %A = < poison, any >
<2 x i8> %B = < poison, #x00 (0) >
<2 x i8> %C = < poison, #x00 (0) >

Target:
<2 x i1> %A = < poison, #x1 (1) >
<2 x i8> %C = < poison, #x01 (1) >
Source value: < poison, #x00 (0) >
Target value: < poison, #x01 (1) >


<a href="https://web.ist.utl.pt/nuno.lopes/alive2/index.php?hash=1546033e6d866cfc&test=Transforms%2FInstCombine%2Fselect-binop-cmp.ll">https://web.ist.utl.pt/nuno.lopes/alive2/index.php?hash=1546033e6d866cfc&test=Transforms%2FInstCombine%2Fselect-binop-cmp.ll</a></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>