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

            Bug ID: 100075
           Summary: [9/10/11 Regression] unneeded sign extension
           Product: gcc
           Version: 10.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luc.vanoostenryck at gmail dot com
  Target Milestone: ---
            Target: aarch64

Created attachment 50588
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50588&action=edit
test case

Until gcc8, the following code:
    struct s {
        short x, y;
    };
    struct s rot(struct s p)
    {
        return (struct s) { -p.y, p.x };
    }

was translated:
    rot90:
        neg     w1, w0, asr 16
        and     w1, w1, 65535
        orr     w0, w1, w0, lsl 16
        ret

but since gcc9 it translates less nicely, with an unneeded sign extension:
    rot90:
        mov     w1, w0
        sbfx    x0, x1, 16, 16
        neg     w0, w0
        bfi     w0, w1, 16, 16
        ret


See with another variant in attachment or https://gcc.godbolt.org/z/1oW1cEMGc

Reply via email to