<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 - does not eliminate a branch on shifts"
   href="https://bugs.llvm.org/show_bug.cgi?id=41647">41647</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>does not eliminate a branch on shifts
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>slandden@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When creating a mask, with unsigned n (I'm doing this in Zig because underflow
is undefined in Zig)

    if (n == 0) {
        return 0;
    } else {
        return u64(math.maxInt(u64)) >> @intCast(u6, ((64 - @intCast(u7, n))));
    }

mask:
        test    dil, dil
        je      .LBB0_1
        neg     dil
        mov     rax, -1
        shrx    rax, rax, rdi
        ret
.LBB0_1:
        xor     eax, eax
        ret

But the branch is unneeded.

<a href="https://www.felixcloutier.com/x86/sarx:shlx:shrx">https://www.felixcloutier.com/x86/sarx:shlx:shrx</a>

If the value specified in the first source operand exceeds OperandSize -1, the
COUNT value is masked.</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>