<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 --- - [InstCombine] icmp slt 0 optimization hinders more optimization"
   href="https://llvm.org/bugs/show_bug.cgi?id=28238">28238</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[InstCombine] icmp slt 0 optimization hinders more optimization
          </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>Spinning this off from <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Optimizer doesn't simplify obvious contradiction"
   href="show_bug.cgi?id=27869">bug 27869</a> (and may have a different solution than <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - InstCombine greediness blocks subsequent optimizations"
   href="show_bug.cgi?id=28221">bug
28221</a>):

int f(int i) {
  return (i == 0) & (i >> 31);
}

'i' can't be 0 and have a bit set, so this should return 0.

$ ./clang -O1 sneaky_icmp.c -S -o - -emit-llvm
...
define i32 @f(i32 %i) {
  %cmp = icmp eq i32 %i, 0
  %conv = zext i1 %cmp to i32
  %shr = ashr i32 %i, 31
  %and = and i32 %conv, %shr
  ret i32 %and
}</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>