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

            Bug ID: 110722
           Summary: FP is Saved/Restored around inline assembly
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: palmer at gcc dot gnu.org
  Target Milestone: ---

I'm not sure if this is some ABI-related requirement that I've managed to
forget about, but it looks like we're saving/restoring FP around inline
assembly.

long fp_asm(long arg0)
{
    asm volatile ("addi a0, a0, 1" : "+r"(arg0));
    return arg0;
}

produces

fp_asm(long):
        addi    sp,sp,-16
        sd      s0,8(sp)
        addi    s0,sp,16
        addi a0, a0, 1
        ld      s0,8(sp)
        addi    sp,sp,16
        jr      ra

We've got a ton of inline assembly in Linux these days and defconfig has
`-fno-omit-frame-pointer`, so this probably manifests as a performance issue
for someone somewhere -- though Clement just ran into it because he was
curious, so I don't have anything concrete.

Reply via email to