<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 - [NewGVN] Miscompile with nonnull metadata"
   href="https://bugs.llvm.org/show_bug.cgi?id=37540">37540</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[NewGVN] Miscompile with nonnull metadata
          </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>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>nikita.ppv@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>NewGVN optimizes:

define i1 @test({}** %arg, i1 %arg2) {
    br i1 %arg2, label %bb1, label %bb2

bb1:
    %load1 = load {}*, {}** %arg
    %cmp1 = icmp eq {}* %load1, null
    ret i1 %cmp1

bb2:
    %load2 = load {}*, {}** %arg, !nonnull !1
    %cmp2 = icmp eq {}* %load2, null
    ret i1 %cmp2
}

!1 = !{}

into:

define i1 @test({}** %arg, i1 %arg2) {
  br i1 %arg2, label %bb1, label %bb2

bb1:                                              ; preds = %0
  ret i1 false

bb2:                                              ; preds = %0
  ret i1 false
}

The reason is that %load1 and %load2 are found congruent with %load2 chosen as
leader. Thus %cmp1 in bb1 calls SimplifyCmp with icmp eq {}* %load2, null,
which is simplified to i1 false based on the !nonnull metadata of %load2.
However, this metadata is not applicable in this branch.

This bug prevents bootstrapping of rustc under newgvn.</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>