https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85683
Bug ID: 85683 Summary: [8 Regression] GCC 8 stopped using RMW (Read Modify Write) instructions on x86[_64] Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: dmitry at zend dot com Target Milestone: --- GCC 8 stopped generation of RMW instructions and uses 3 instructions instead of one. Although, this shouldn't affect executed uops, this increases code size (pressure to instruction decoder and instruction cache) and requires an extra register (that may cause extra spills and related degradations). === test_rmw.c === typedef struct _refcounted { unsigned int refcount; } refcounted; typedef struct _value { refcounted *val; } value; extern void value_dtor_func(refcounted *val); void ptr_dtor(value *ptr) { refcounted *ref = ptr->val; --ref->refcount; if (ref->refcount == 0) { value_dtor_func(ref); } } === $ gcc -O2 -S test_rmw.c $ cat test_rmw.s movq (%rdi), %rdi movl (%rdi), %eax subl $1, %eax movl %eax, (%rdi) je .L4 ret .L4: jmp value_dtor_func