Bug 42226 - [missed optimization] inefficient byte access when -Os is specified
Summary: [missed optimization] inefficient byte access when -Os is specified
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.5.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2009-11-30 08:55 UTC by Carrot
Modified: 2021-07-26 08:09 UTC (History)
3 users (show)

See Also:
Host: i686-linux
Target: arm-eabi
Build: i686-linux
Known to work:
Known to fail:
Last reconfirmed: 2021-07-26 00:00:00


Attachments
test case (80 bytes, text/plain)
2009-11-30 08:56 UTC, Carrot
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carrot 2009-11-30 08:55:52 UTC
Compile the attached test case with options -Os -mthumb, gcc generates:

        add     r1, r1, #40
        mov     r3, r0
        ldrb    r2, [r1]
        add     r3, r3, #40
        strb    r2, [r3]
        @ sp needed for prologue
        bx      lr

When change the options to -O2 -mthumb, gcc generates:

        mov     r3, #40
        ldrb    r2, [r1, r3]
        strb    r2, [r0, r3]
        @ sp needed for prologue
        bx      lr

It is both smaller and faster.

Compare the dumped IL with different options, all TREE expressions are identical. The first difference occurs after rtl expanding.
Comment 1 Carrot 2009-11-30 08:56:11 UTC
Created attachment 19184 [details]
test case
Comment 2 Richard Biener 2009-11-30 10:33:54 UTC
I suspect it's rtx costs messed up if asked for speed vs. size metrics.
Comment 3 Ramana Radhakrishnan 2009-12-09 15:48:59 UTC
Only with trunk - this is a performance and size regression. 

The correct answer might be to define thumb1 specific size costs . At the minute thumb1_rtx_costs is used for both speed and size.