Re:No sane compiler would optimize atomics (2015)
by Someone on Monday July 12, 2021 @03:42AM
(#27808015)
I think it’s only less surprising because it happens more often, so that ‘everybody’ knows about it, not because it is inherently less strange.
As examples of merging, if you do
s = sin(x)
c = cos(x)
would you find it surprising if that generated a single sincos instruction if the CPU has one?
If you do
typedef struct s { char a; char b; }
s c;
[…]
c.a = 3;
c.b = 6;
do you find it surprising if the compiler generates a single instruction that is equivalent to (exact code will vary according to the CPU architecture, and this may need a further cast to avoid undefined behavior):
As examples of merging, if you do
would you find it surprising if that generated a single sincos instruction if the CPU has one?If you do
do you find it surprising if the compiler generates a single instruction that is equivalent to (exact code will vary according to the CPU architecture, and this may need a further cast to avoid undefined behavior):