This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/53869] Redundant memory load
- From: "unixoid2003 at mail dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 06 Jul 2012 06:16:05 +0000
- Subject: [Bug tree-optimization/53869] Redundant memory load
- Auto-submitted: auto-generated
- References: <bug-53869-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53869
--- Comment #1 from brag <unixoid2003 at mail dot ru> 2012-07-06 06:16:05 UTC ---
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