<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 --- - Binary rotation is not detected after multiplication"
   href="https://llvm.org/bugs/show_bug.cgi?id=31275">31275</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Binary rotation is not detected after multiplication
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>funny.falcon@gmail.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>I found that clang produces bad code for rotation after multiplication.
Although it generates good code, if multiplication is not last operation:

// Type your code here, or load an example.
#define rotl(x,n) (((x)<<(n))|((x)>>(32-(n))))
unsigned mult_rotl(unsigned num, unsigned mun) {
    return rotl(num*9, 7);
}
unsigned mult_add_rotl(unsigned num, unsigned mun) {
    return rotl(num*9+1, 7);
}

mult_rotl:
        leal    (%rdi,%rdi,8), %eax
        shll    $7, %edi
        leal    (%rdi,%rdi,8), %ecx
        shrl    $25, %eax
        orl     %ecx, %eax
        retq
mult_add_rotl:
        leal    1(%rdi,%rdi,8), %eax
        roll    $7, %eax
        retq

(probably, it is llvm-optimizer's issue)</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>