public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/96770] New: -mpure-code produces suboptimal code for relocations with small offset for thumb-1
@ 2020-08-24 13:30 clyon at gcc dot gnu.org
  2020-09-08 12:51 ` [Bug target/96770] " clyon at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: clyon at gcc dot gnu.org @ 2020-08-24 13:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96770

            Bug ID: 96770
           Summary: -mpure-code produces suboptimal code for relocations
                    with small offset for thumb-1
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: clyon at gcc dot gnu.org
  Target Milestone: ---

As discussed in PR94538, -mpure-code produces suboptimal code for relocations
with small offset for thumb-1.

int arr[10];
int *f4 (void) { return &arr[1]; }

Compiled with -O2 -mpure-code,
-mcpu=cortex-m0:
f4:
        movs    r3, #:upper8_15:#.LC0
        lsls    r3, #8
        adds    r3, #:upper0_7:#.LC0
        lsls    r3, #8
        adds    r3, #:lower8_15:#.LC0
        lsls    r3, #8
        adds    r3, #:lower0_7:#.LC0
        @ sp needed
        ldr     r0, [r3]
        adds    r0, r0, #4
        bx      lr

We should avoid the extra load from the literal pool (related to PR96767), and
the 'adds r0,r0,4'.

-mcpu=cortex-m23:
f4:
        movw    r0, #:lower16:.LANCHOR0
        @ sp needed
        movt    r0, #:upper16:.LANCHOR0
        adds    r0, r0, #4
        bx      lr

For reference, -mcpu=cortex-m3 produces:
f4:
        movw    r0, #:lower16:.LANCHOR0+4
        movt    r0, #:upper16:.LANCHOR0+4
        bx      lr

We should generate the same code for cortex-m23.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-04-16 19:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-24 13:30 [Bug target/96770] New: -mpure-code produces suboptimal code for relocations with small offset for thumb-1 clyon at gcc dot gnu.org
2020-09-08 12:51 ` [Bug target/96770] " clyon at gcc dot gnu.org
2020-09-28  9:10 ` clyon at gcc dot gnu.org
2020-11-02  7:35 ` cvs-commit at gcc dot gnu.org
2020-11-09 12:26 ` clyon at gcc dot gnu.org
2021-03-28 19:01 ` cvs-commit at gcc dot gnu.org
2021-04-16 19:59 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).