<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 --- - Inverted conditionals not being CSEd"
   href="https://llvm.org/bugs/show_bug.cgi?id=23333">23333</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inverted conditionals not being CSEd
          </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>Linux
          </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>listmail@philipreames.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We currently fail to recognize the CSE oppurtunity in the following example in
EarlyCSE or JumpThreading.  GVN does get this case:
define i8 @earlycse(i8 addrspace(1)* %ptr) {
   %cnd = icmp eq i8 addrspace(1)* %ptr, null
   br i1 %cnd, label %null, label %not_null
null:
   %cnd2 = icmp ne i8 addrspace(1)* %ptr, null
   %res = select i1 %cnd2, i8 2, i8 1
   ret i8 %res

not_null:
   ret i8 0
}

For EarlyCSE:
When we encounter %cnd2, we could lookup it's inverse in the SimpleValue
structure and use the negation of that check.  

For JumpThreading:
We should know that %ptr == null at the compare.  We just don't appear to be
using this fact at all.

Alternatively, we could choose to canonicalize the NE to an EQ case and invert
the select.  If that approach was chosen, InstCombine might be a more
reasonable place.</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>