<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 - Merging GEP inbounds of GEP incorrectly preserves inbounds"
   href="https://bugs.llvm.org/show_bug.cgi?id=44425">44425</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Merging GEP inbounds of GEP incorrectly preserves inbounds
          </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>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>nikita.ppv@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>define i32* @test_gep2(i32* %base) {
  %ptr1 = getelementptr i32, i32* %base, i64 4
  %ptr2 = getelementptr inbounds i32, i32* %ptr1, i64 4
  ret i32* %ptr2
}

opt -instcombine

define i32* @test_gep2(i32* %base) {
  %ptr2 = getelementptr inbounds i32, i32* %base, i64 8
  ret i32* %ptr2
}

I believe this this transform isn't correct, e.g. if the original %base was
pointing 4 elements before the start of an object.

This only happens in the case where the GEP is updated in-place.

Noticed this while looking into <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - LLVM 10 regression in gep inbounds of zero-offset gep"
   href="show_bug.cgi?id=44423">https://bugs.llvm.org/show_bug.cgi?id=44423</a>...</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>