This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/53870] New: 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:12:33 +0000
- Subject: [Bug tree-optimization/53870] New: Redundant memory load
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: unixoid2003@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