http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53870
Bug #: 53870 Summary: Redundant memory load Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: minor Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: unixoid2...@mail.ru class test{ public: void remove(); private: test *next; test *prev; }; void test::remove(){ next->prev=prev; prev->next=next; } arm-none-eabi-gcc++ -mcpu=cortex-m3 -mthumb -O2 00000000 <_ZN4test6removeEv>: 0: 6803 ldr r3, [r0, #0] 2: 6842 ldr r2, [r0, #4] 4: 605a str r2, [r3, #4] 6: 6842 ldr r2, [r0, #4] ; Redundant 8: 6013 str r3, [r2, #0] a: 4770 bx lr But this code compiles better: void test::remove(){ test *n=next,*p=prev; n->prev=p; p->next=n; } 00000000 <_ZN4test6removeEv>: 0: e890 000c ldmia.w r0, {r2, r3} 4: 6053 str r3, [r2, #4] 6: 601a str r2, [r3, #0] 8: 4770 bx lr