News for hackers. Stuff that matters.
Re:No Sane Compiler Would Optimize Atomics by mike_hock on Saturday May 14, 2016 @08:18AM (#11695765)
> Example: you pass an object by value, and only read one field, can it optimize this?

Yes.

    struct S { int a,b; };
    void foo(int); // Some external function
    void bar(S s) { foo(s.a); }
    void baz() { bar(S{42, 55}); }
compiles the baz function to (-O2 on GCC 4.9)

    movl    $42, %edi
    jmp     _Z3fooi

There are no comments on this comment yet.