Bug 52256 - Hoist the memory load from both branches of if statement
Summary: Hoist the memory load from both branches of if statement
Status: RESOLVED DUPLICATE of bug 23286
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-15 08:29 UTC by Carrot
Modified: 2023-12-28 07:18 UTC (History)
1 user (show)

See Also:
Host:
Target: arm-unknown-linux-gnueabi
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carrot 2012-02-15 08:29:53 UTC
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.
Comment 1 Richard Biener 2012-02-15 11:19:55 UTC
That's not CSE that's code hoisting.

*** This bug has been marked as a duplicate of bug 23286 ***