[all-commits] [llvm/llvm-project] 23595d: [AArch64] Lower __builtin_bswap16 to rev16 if bswa...

adprasad-nvidia via All-commits all-commits at lists.llvm.org
Tue Sep 10 02:57:28 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 23595d1b9621067e5354924e2ca78e866a85690e
      https://github.com/llvm/llvm-project/commit/23595d1b9621067e5354924e2ca78e866a85690e
  Author: adprasad-nvidia <adprasad at nvidia.com>
  Date:   2024-09-10 (Tue, 10 Sep 2024)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
    M llvm/lib/Target/AArch64/AArch64InstrInfo.td
    M llvm/test/CodeGen/AArch64/bswap.ll

  Log Message:
  -----------
  [AArch64] Lower __builtin_bswap16 to rev16 if bswap followed by any_extend (#105375)

GCC compiles the built-in function `__builtin_bswap16`, to the ARM
instruction rev16, which reverses the byte order of 16-bit data. On the
other Clang compiles the same built-in function to e.g.
```     
        rev     w8, w0
        lsr     w0, w8, #16
```
i.e. it performs a byte reversal of a 32-bit register, (which moves the
lower half, which contains the 16-bit data, to the upper half) and then
right shifts the reversed 16-bit data back to the lower half of the
register.
We can improve Clang codegen by generating `rev16` instead of `rev` and
`lsr`, like GCC.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list