<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 --- - print a remark when an llvm.assume has a false param"
   href="https://llvm.org/bugs/show_bug.cgi?id=31882">31882</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>print a remark when an llvm.assume has a false param
          </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>Filing this based on Daniel's example in:
<a href="https://reviews.llvm.org/D29404">https://reviews.llvm.org/D29404</a>

declare void @llvm.assume(i1) nounwind
define i32 @assume_false(i32 %p) {
entry:
   %cmp = icmp eq i32 %p, 42
   call void @llvm.assume(i1 %cmp)
   br i1 %cmp, label %bb2, label %bb3
bb2:
   %cmp3 = icmp eq i32 %p, 43
   call void @llvm.assume(i1 %cmp3)
   ret i32 15
bb3:
   ret i32 17
}

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

-instsimplify tells us that the 2nd icmp is false via isKnownNonEqual() which
calls computeKnownBits() which calls computeKnownBitsFromAssume():

$ ./opt -instsimplify badass.ll -S
...
declare void @llvm.assume(i1) #0

define i32 @assume_false(i32 %p) {
entry:
  %cmp = icmp eq i32 %p, 42
  call void @llvm.assume(i1 %cmp)
  br i1 %cmp, label %bb2, label %bb3

bb2:                          
  call void @llvm.assume(i1 false)   <--- oops...alternative facts!
  ret i32 15

bb3:    
  ret i32 17
}


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

As mentioned in D29404, we can't print a strong warning, but we can at least
print a weasel-worded remark because it's likely that either the program or the
compiler has a bug when a condition that was supposed to be true was proven
false.</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>