This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/52256] New: CSE the memory load from both branches of if statement
- From: "carrot at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 15 Feb 2012 08:29:53 +0000
- Subject: [Bug tree-optimization/52256] New: CSE the memory load from both branches of if statement
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52256
Bug #: 52256
Summary: CSE the memory load from both branches of if statement
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: carrot@google.com
Target: arm-unknown-linux-gnueabi
In mcfutils.c of mcf from SPEC, function refresh_potential() contains following
code snippet
...
85 if( node->orientation == UP )
86 node->potential = node->basic_arc->cost +
node->pred->potential;
87 else /* == DOWN */
88 {
89 node->potential = node->pred->potential -
node->basic_arc->cost;
90 checksum++;
91 }
...
Compile it with options -march=armv7-a -mthumb -Os, gcc 4.7 generates
...
71 ldr r2, [r3, #4]
72 ldr r4, [r3, #12]
73 cmp r2, #1
74 ldr r2, [r3, #24]
75 bne .L8
76 ldr r5, [r2, #0] //common memory load
77 ldr r2, [r4, #0] //common memory load
78 adds r2, r5, r2
79 str r2, [r3, #0]
80 b .L9
81 .L8:
82 ldr r4, [r4, #0] //common memory load
83 adds r0, r0, #1
84 ldr r2, [r2, #0] //common memory load
85 subs r2, r4, r2
86 str r2, [r3, #0]
87 .L9:
...
The memory node->basic_arc->cost and node->pred->potential are loaded in both
branches of the if statement, so we can CSE them. But current gcc CSE only
node->basic_arc and node->pred.