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

            Bug ID: 126283
           Summary: Extra register move in __builtin_bswap16 on x86-64
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com
  Target Milestone: ---

// https://godbolt.org/z/9vozroWMn
int f(short x) {
    return __builtin_bswap16(x);
}

GCC 14.4 (x86-64) produces:
  rolw $8, %di
  movzwl %di, %eax
  ret

GCC 15.1 (x86-64), and trunk as of this writing, produces one additional
register move:
  movl %edi, %eax
  rolw $8, %ax
  movzwl %ax, %eax
  ret

Doesn't have any business impact, obviously, but I thought it was strange that
it would have regressed, and might be worth tracking down why.

Reply via email to