<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - [InstSimplify] missing vector icmp with constant edge case patterns"
   href="https://llvm.org/bugs/show_bug.cgi?id=27734">27734</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[InstSimplify] missing vector icmp with constant edge case patterns
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>spatel+llvm@rotateright.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This was noted in <a href="http://reviews.llvm.org/D17859">http://reviews.llvm.org/D17859</a> where we semi-canonicalized
vector integer LE/GE comparisons: we're missing 3 out 4 of the vector
transforms when doing an icmp against an edge case constant:

define i1 @scalar_uge_true(i4 %x) {
  %cmp = icmp uge i4 %x, 0
  ret i1 %cmp
}

define i1 @scalar_ule_true(i4 %x) {
  %cmp = icmp ule i4 %x, 15
  ret i1 %cmp
}

define i1 @scalar_sge_true(i4 %x) {
  %cmp = icmp sge i4 %x, -8
  ret i1 %cmp
}

define i1 @scalar_sle_true(i4 %x) {
  %cmp = icmp sle i4 %x, 7
  ret i1 %cmp
}

define <4 x i1> @vector_uge_true(<4 x i4> %x) {
  %cmp = icmp uge <4 x i4> %x, zeroinitializer
  ret <4 x i1> %cmp
}

define <4 x i1> @vector_ule_true(<4 x i4> %x) {
  %cmp = icmp ule <4 x i4> %x, <i4 15, i4 15, i4 15, i4 15>
  ret <4 x i1> %cmp
}

define <4 x i1> @vector_sge_true(<4 x i4> %x) {
  %cmp = icmp sge <4 x i4> %x, <i4 -8, i4 -8, i4 -8, i4 -8>
  ret <4 x i1> %cmp
}

define <4 x i1> @vector_sle_true(<4 x i4> %x) {
  %cmp = icmp sle <4 x i4> %x, <i4 7, i4 7, i4 7, i4 7>
  ret <4 x i1> %cmp
}

------------------------------------------------------------------------

$ ./opt -instsimplify vec_icmp.ll -S
...

define i1 @scalar_uge_true(i4 %x) {
  ret i1 true
}

define i1 @scalar_ule_true(i4 %x) {
  ret i1 true
}

define i1 @scalar_sge_true(i4 %x) {
  ret i1 true
}

define i1 @scalar_sle_true(i4 %x) {
  ret i1 true
}

define <4 x i1> @vector_uge_true(<4 x i4> %x) {
  ret <4 x i1> <i1 true, i1 true, i1 true, i1 true>
}

define <4 x i1> @vector_ule_true(<4 x i4> %x) {
  %cmp = icmp ule <4 x i4> %x, <i4 -1, i4 -1, i4 -1, i4 -1>
  ret <4 x i1> %cmp
}

define <4 x i1> @vector_sge_true(<4 x i4> %x) {
  %cmp = icmp sge <4 x i4> %x, <i4 -8, i4 -8, i4 -8, i4 -8>
  ret <4 x i1> %cmp
}

define <4 x i1> @vector_sle_true(<4 x i4> %x) {
  %cmp = icmp sle <4 x i4> %x, <i4 7, i4 7, i4 7, i4 7>
  ret <4 x i1> %cmp
}</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>