[llvm-bugs] [Bug 31275] New: Binary rotation is not detected after multiplication

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 5 10:11:31 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=31275

            Bug ID: 31275
           Summary: Binary rotation is not detected after multiplication
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: funny.falcon at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

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)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161205/5e0864d9/attachment.html>


More information about the llvm-bugs mailing list