https://llvm.org/bugs/show_bug.cgi?id=31162
Bug ID: 31162 Summary: LLVM (Clang) failed to optimized little-endian integer composition Product: new-bugs Version: trunk Hardware: PC OS: Linux Status: NEW Severity: enhancement Priority: P Component: new bugs Assignee: unassignedb...@nondot.org Reporter: peetluge...@yandex.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Clang/LLVM is unable to optimize this: uint32_t read32le(const uint8_t* ptr) { return (static_cast<uint32_t>(ptr[0]) & 0x000000FFu) | ((static_cast<uint32_t>(ptr[1]) << 8) & 0x0000FF00u) | ((static_cast<uint32_t>(ptr[2]) << 16) & 0x00FF0000u) | ((static_cast<uint32_t>(ptr[3]) << 24) & 0xFF000000u); } LLVM code: read32le(unsigned char const*): movzx eax, byte ptr [rdi] movzx ecx, byte ptr [rdi + 1] shl ecx, 8 or ecx, eax movzx edx, byte ptr [rdi + 2] shl edx, 16 or edx, ecx movzx eax, byte ptr [rdi + 3] shl eax, 24 or eax, edx ret GCC (7) code: read32le(unsigned char const*): mov eax, DWORD PTR [rdi] ret -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs