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: unassignedclangb...@nondot.org
          Reporter: esol...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to