[PATCH] D151870: [ARM] Increase cost of unaligned double and float loads

Sam Tebbs via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 03:10:29 PDT 2023


samtebbs added a comment.

In D151870#4394292 <https://reviews.llvm.org/D151870#4394292>, @efriedma wrote:

> clang generates unaligned load/store for something like the following:
>
>   float f(char* x) { float a; __builtin_memcpy(&a, x, sizeof(a)); return a; }
>   float ff(char* x, float f) { __builtin_memcpy(x, &f, sizeof(f)); }
>   double d(char* x) { double a; __builtin_memcpy(&a, x, sizeof(a)); return a; }
>   double dd(char* x, double f) { __builtin_memcpy(x, &f, sizeof(f)); }

Thanks for that, I'll add some of those as a test case.

> Looking at the generated code for this, not sure how you get a cost of "6" for double; I only count 4 instructions (https://godbolt.org/z/6rodoPMqj)

Perhaps my use case was a bit more complex and resulted in more instructions. I'll change it to 4 and see how it works.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151870/new/

https://reviews.llvm.org/D151870



More information about the llvm-commits mailing list