<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 - GVN drops nonnull metadata"
   href="https://bugs.llvm.org/show_bug.cgi?id=35038">35038</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>GVN drops nonnull metadata
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>5.0
          </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>enhancement
          </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>yyc1992@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Very similar to <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - instcombine drops load !nonnull metadata on an inttoptr/ptrtoint"
   href="show_bug.cgi?id=30597">https://bugs.llvm.org/show_bug.cgi?id=30597</a> and
<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - SROA is dropping !nonnull/!range metadata"
   href="show_bug.cgi?id=31142">https://bugs.llvm.org/show_bug.cgi?id=31142</a> but for GVN this time.

Code to reproduce:

```
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i8* @f(i8** %v0, i8** %v1) {
top:
  %v2 = load i8*, i8** %v0, !nonnull !0
  store i8* %v2, i8** %v1
  %v3 = load i8*, i8** %v1
  ret i8* %v3
}

!0 = !{}
```

Running GVN produces

```
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i8* @f(i8** %v0, i8** %v1) {
top:
  %v2 = load i8*, i8** %v0
  store i8* %v2, i8** %v1
  ret i8* %v2
}
```

while running instcombine produces

```
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i8* @f(i8** %v0, i8** %v1) {
top:
  %0 = bitcast i8** %v0 to i64*
  %v21 = load i64, i64* %0, align 8, !range !0
  %1 = bitcast i8** %v1 to i64*
  store i64 %v21, i64* %1, align 8
  %v3.cast = inttoptr i64 %v21 to i8*
  ret i8* %v3.cast
}

!0 = !{i64 1, i64 0}
```

The GVN version has deleted the `!nonnull` metadata on the load.</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>