<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 - [AssumeBundles] ValueTracking cannot use alignment assumptions"
   href="https://bugs.llvm.org/show_bug.cgi?id=48224">48224</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[AssumeBundles] ValueTracking cannot use alignment assumptions
          </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>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Global Analyses
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nikolai.bozhenov@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This is a regression caused by switch to using operand bundles to encode
alignment assumptions
(<a href="https://reviews.llvm.org/rG78de7297abe2e8fa782682168989c70e3cb34a5c">https://reviews.llvm.org/rG78de7297abe2e8fa782682168989c70e3cb34a5c</a>).

It looks like the ValueTracking (computeKnownBits) cannot understand the new
format of alignment assumptions. As an example, consider compilation of the
following reproducer with clang-11 (old @llvm.assume format) and clang-trunk
(@llvm.assume with bundles):

  #include <stdint.h>
  int foo(int *p) {
    __builtin_assume_aligned(p, 32);
    return ((intptr_t) p) & 4;
  }

clang-11 (<a href="https://godbolt.org/z/xGh1e4">https://godbolt.org/z/xGh1e4</a>) computes the returned value statically:

  ret i32 0

clang-trunk (<a href="https://godbolt.org/z/1jWe5j">https://godbolt.org/z/1jWe5j</a>) fails to optimize the code:

  %3 = ptrtoint i32* %0 to i64
  %4 = trunc i64 %3 to i32
  %5 = and i32 %4, 4
  ret i32 %5

As one can see, after switching to operand bundles, clang-trunk lost its
ability to reason about low bits in aligned pointers.</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>