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

            Bug ID: 127288
           Summary: missing use of sbfx in a simple example
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64

Take:
```
void f(long long *a, int *b)
{
    *a = *b>>2;
}
```

LLVM produces:
```
        ldr     w8, [x1]
        sbfx    x8, x8, #2, #30
        str     x8, [x0]
        ret
```

While GCC produces:
```
        ldr     w1, [x1]
        asr     w1, w1, 2
        sxtw    x1, w1
        str     x1, [x0]
        ret
```

The asr/sxtw pair can be reduced to just sbfx instruction.

Reply via email to