[llvm-bugs] [Bug 41875] New: Incorrect code is generated for rotation of 32-bit value to 32-bits

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 14 08:37:52 PDT 2019


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

            Bug ID: 41875
           Summary: Incorrect code is generated for rotation of 32-bit
                    value to 32-bits
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: esolosh at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

I'm using https://clang.godbolt.org/ with the following settings:
Compiler: x86-64 clang 8.0.0
Options: -Os

Test code:  
```
#include <stdint.h>

extern uint32_t v32;

void rotate_32 (void)
{
    uint32_t x = v32;
    int n = 32;
    v32 = (x >> n) | (x << (32 - n));   /* rotate right to 32-bits */
}
```

Disassembly:  
```
rotate_32:                              # @rotate_32
        mov     dword ptr [rip + v32], -1
        ret
```

I expect that value in v32 does not change, but -1 is loaded instead.

Also can be observed with other clang version and other optimization levels
(-O1, -O2, -O3).

-- 
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/20190514/87046519/attachment.html>


More information about the llvm-bugs mailing list