<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] Select based on sign bit condition not canonicalized"
   href="https://bugs.llvm.org/show_bug.cgi?id=44521">44521</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[InstCombine] Select based on sign bit condition not canonicalized
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nikita.ppv@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following stay invariant under -instcombine:

define i8 @sign_select_scalar_sgt(i8 %cond, i8 %tval, i8 %fval) {
  %cmp = icmp sgt i8 %cond, -1
  %res = select i1 %cmp, i8 %fval, i8 %tval
  ret i8 %res
}
define i8 @sign_select_scalar_slt(i8 %cond, i8 %tval, i8 %fval) {
  %cmp = icmp slt i8 %cond, 0
  %res = select i1 %cmp, i8 %tval, i8 %fval
  ret i8 %res
}
define <4 x i8> @sign_select_vec_sgt(<4 x i8> %cond, <4 x i8> %tval, <4 x i8>
%fval) {
  %cmp = icmp sgt <4 x i8> %cond, <i8 -1, i8 -1, i8 -1, i8 -1>
  %res = select <4 x i1> %cmp, <4 x i8> %fval, <4 x i8> %tval
  ret <4 x i8> %res
}
define <4 x i8> @sign_select_vec_slt(<4 x i8> %cond, <4 x i8> %tval, <4 x i8>
%fval) {
  %cmp = icmp slt <4 x i8> %cond, zeroinitializer
  %res = select <4 x i1> %cmp, <4 x i8> %tval, <4 x i8> %fval
  ret <4 x i8> %res
}

I would expect that this gets canonicalized one way or another (<0 probably).

Noticed this when some InstCombine worklist order changes resulted in the above
patterns getting flipped in places.</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>