[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc
Subject: atomic_load: code generation 64 bit for struct
From: "Uecker, Martin" <Martin.Uecker () med ! uni-goettingen ! de>
Date: 2020-06-28 19:00:11
Message-ID: 1593370810.3723.7.camel () med ! uni-goettingen ! de
[Download RAW message or body]
Hi all,
the following code compiles into a mov instruction
on x86_64. I wonder why. The struct has alignment 4,
so a mov might not be atomic if the struct is not
alligned to its full size. For this reason,
I expected a call to libatomic instead
(LLVM does this). What am I missing?
The documentation implies that this should work
for all types.
typedef struct { float re; float im; } yy_t;
yy_t bar2(yy_t* x)
{
yy_t r;
__atomic_load(x, &r, __ATOMIC_SEQ_CST);
return r;
}
https://godbolt.org/z/XcDkG_
Best,
Martin
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic