<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 --- - umulll_overflow with constant powers of two are not well optimized"
   href="https://llvm.org/bugs/show_bug.cgi?id=28426">28426</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>umulll_overflow with constant powers of two are not well optimized
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jmuizelaar@mozilla.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>bool k(unsigned long long i) {
        unsigned long long result;
        return __builtin_umulll_overflow(i, 4, &result);
}

compiles to:

        movl    $4, %ecx
        movq    %rdi, %rax
        mulq    %rcx
        seto    %al
        retq

A better alternative would be this code:

bool k(unsigned long long i)
{
        return i >> (64-2);
}

which compiles to:

        shrq    $62, %rdi
        setne   %al
        retq

This idiom comes from compiled rust code which does an overflow check when
allocating Vecs so it is quite prevalent.</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>