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

            Bug ID: 123164
           Summary: RV: redundant sp adjustment, when struct is passed via
                    GPRs
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: camel-cdr at protonmail dot com
  Target Milestone: ---
            Target: riscv

int ifoo(struct { int a, b; } a) { return a.a + a.b; }

compiled with -O2 or -O3 generates: https://godbolt.org/z/E5v1jn95j

ifoo:
        addi    sp,sp,-16 # redundant
        srli    a5,a0,32
        addw    a0,a0,a5
        addi    sp,sp,16 # redundant
        jr      ra

Also, -Os generates a redundant move.

Reply via email to