# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
# RUN: llc -mtriple=i386-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefix=X86-32
# RUN: llc -mtriple=x86_64-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefix=X86-64
# test bswap for s16, s32, and s64
---
name: test_bswap64
body: |
bb.1:
; X86-32-LABEL: name: test_bswap64
; X86-32: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
; X86-32-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[DEF]](s64)
; X86-32-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[UV1]]
; X86-32-NEXT: [[BSWAP1:%[0-9]+]]:_(s32) = G_BSWAP [[UV]]
; X86-32-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[BSWAP]](s32), [[BSWAP1]](s32)
; X86-32-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[MV]](s64)
; X86-32-NEXT: RET 0, implicit [[COPY]](s64)
; X86-64-LABEL: name: test_bswap64
; X86-64: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
; X86-64-NEXT: [[BSWAP:%[0-9]+]]:_(s64) = G_BSWAP [[DEF]]
; X86-64-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[BSWAP]](s64)
; X86-64-NEXT: RET 0, implicit [[COPY]](s64)
%0:_(s64) = IMPLICIT_DEF
%1:_(s64) = G_BSWAP %0
%2:_(s64) = COPY %1(s64)
RET 0, implicit %2
...
---
name: test_bswap32
body: |
bb.1:
; X86-32-LABEL: name: test_bswap32
; X86-32: [[DEF:%[0-9]+]]:_(s32) = IMPLICIT_DEF
; X86-32-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[DEF]]
; X86-32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY [[BSWAP]](s32)
; X86-32-NEXT: RET 0, implicit [[COPY]](s32)
; X86-64-LABEL: name: test_bswap32
; X86-64: [[DEF:%[0-9]+]]:_(s32) = IMPLICIT_DEF
; X86-64-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[DEF]]
; X86-64-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY [[BSWAP]](s32)
; X86-64-NEXT: RET 0, implicit [[COPY]](s32)
%0:_(s32) = IMPLICIT_DEF
%1:_(s32) = G_BSWAP %0
%2:_(s32) = COPY %1(s32)
RET 0, implicit %2
...
---
name: test_bswap16
body: |
bb.1:
; X86-32-LABEL: name: test_bswap16
; X86-32: [[DEF:%[0-9]+]]:_(s16) = IMPLICIT_DEF
; X86-32-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[DEF]](s16)
; X86-32-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[ANYEXT]]
; X86-32-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 16
; X86-32-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[BSWAP]], [[C]](s8)
; X86-32-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[LSHR]](s32)
; X86-32-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY [[TRUNC]](s16)
; X86-32-NEXT: RET 0, implicit [[COPY]](s16)
; X86-64-LABEL: name: test_bswap16
; X86-64: [[DEF:%[0-9]+]]:_(s16) = IMPLICIT_DEF
; X86-64-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[DEF]](s16)
; X86-64-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[ANYEXT]]
; X86-64-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 16
; X86-64-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[BSWAP]], [[C]](s8)
; X86-64-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[LSHR]](s32)
; X86-64-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY [[TRUNC]](s16)
; X86-64-NEXT: RET 0, implicit [[COPY]](s16)
%0:_(s16) = IMPLICIT_DEF
%1:_(s16) = G_BSWAP %0
%2:_(s16) = COPY %1(s16)
RET 0, implicit %2
...