[llvm-bugs] [Bug 32230] Overestimated align on load

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 11 00:00:54 PST 2017


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

David Majnemer <david.majnemer at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |david.majnemer at gmail.com
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from David Majnemer <david.majnemer at gmail.com> ---
This works as intended, the compiler is obligated to use the alignment of
uint64_t for the load which, in this case, is eight bytes.

If you want to achieve the desired effect, do the following instead:

#include <cstdint>
#include <cstring>
using namespace std;

void test(uint8_t *ptr, long *buf, int const N) {
  for (int I = 0; I < N - 7; ++I) {
    uint64_t big;
    memcpy(&big, ptr + I, sizeof(big));
    buf[I] = big * big;
  }
}

In the IR, you will now see something along the lines of:
%14 = load i64, i64* %13, align 1

-- 
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/20170311/7bc1241e/attachment.html>


More information about the llvm-bugs mailing list