https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111844

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-10-17
             Status|UNCONFIRMED                 |NEW
           Severity|normal                      |enhancement
           Keywords|                            |missed-optimization
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect LLVM is able to just optimize it to:
#include <cstddef>


void foo1(void* buf, int inc) {
    unsigned int px;
    memcpy(&px, ((char*)buf)+offsetof(P, x), sizeof(px)) ;
    px += inc;
    memcpy(((char*)buf)+offsetof(P, x), &px, sizeof(px)) ;

   //  bar();
}

As it can see that is the only location is changed ...

Reply via email to