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

            Bug ID: 96767
           Summary: -mpure-code produces indirect loads 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 described in PR94538, -mpure-code produces suboptimal code for thumb-1 CPUs.

int x;
int f1 (void) { return x; }
Compiled with -O2 -mpure-code,
-mcpu=cortex-m0:
        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     r3, [r3]
        ldr     r0, [r3]
        bx      lr
-> extra indirection, there should be only one ldr

For reference, -mcpu=cortex-m[347] and m23 produce:
        movw    r3, #:lower16:.LANCHOR0
        movt    r3, #:upper16:.LANCHOR0
        ldr     r0, [r3]
        bx      lr

Reply via email to