1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
2 # RUN: llc -mtriple=i386-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefix=X86-32
3 # RUN: llc -mtriple=x86_64-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefix=X86-64
5 # test bswap for s16, s32, and s64
11 ; X86-32-LABEL: name: test_bswap64
12 ; X86-32: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
13 ; X86-32-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[DEF]](s64)
14 ; X86-32-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[UV1]]
15 ; X86-32-NEXT: [[BSWAP1:%[0-9]+]]:_(s32) = G_BSWAP [[UV]]
16 ; X86-32-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[BSWAP]](s32), [[BSWAP1]](s32)
17 ; X86-32-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[MV]](s64)
18 ; X86-32-NEXT: RET 0, implicit [[COPY]](s64)
19 ; X86-64-LABEL: name: test_bswap64
20 ; X86-64: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
21 ; X86-64-NEXT: [[BSWAP:%[0-9]+]]:_(s64) = G_BSWAP [[DEF]]
22 ; X86-64-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[BSWAP]](s64)
23 ; X86-64-NEXT: RET 0, implicit [[COPY]](s64)
24 %0:_(s64) = IMPLICIT_DEF
25 %1:_(s64) = G_BSWAP %0
26 %2:_(s64) = COPY %1(s64)
34 ; X86-32-LABEL: name: test_bswap32
35 ; X86-32: [[DEF:%[0-9]+]]:_(s32) = IMPLICIT_DEF
36 ; X86-32-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[DEF]]
37 ; X86-32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY [[BSWAP]](s32)
38 ; X86-32-NEXT: RET 0, implicit [[COPY]](s32)
39 ; X86-64-LABEL: name: test_bswap32
40 ; X86-64: [[DEF:%[0-9]+]]:_(s32) = IMPLICIT_DEF
41 ; X86-64-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[DEF]]
42 ; X86-64-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY [[BSWAP]](s32)
43 ; X86-64-NEXT: RET 0, implicit [[COPY]](s32)
44 %0:_(s32) = IMPLICIT_DEF
45 %1:_(s32) = G_BSWAP %0
46 %2:_(s32) = COPY %1(s32)
54 ; X86-32-LABEL: name: test_bswap16
55 ; X86-32: [[DEF:%[0-9]+]]:_(s16) = IMPLICIT_DEF
56 ; X86-32-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[DEF]](s16)
57 ; X86-32-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[ANYEXT]]
58 ; X86-32-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 16
59 ; X86-32-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[BSWAP]], [[C]](s8)
60 ; X86-32-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[LSHR]](s32)
61 ; X86-32-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY [[TRUNC]](s16)
62 ; X86-32-NEXT: RET 0, implicit [[COPY]](s16)
63 ; X86-64-LABEL: name: test_bswap16
64 ; X86-64: [[DEF:%[0-9]+]]:_(s16) = IMPLICIT_DEF
65 ; X86-64-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[DEF]](s16)
66 ; X86-64-NEXT: [[BSWAP:%[0-9]+]]:_(s32) = G_BSWAP [[ANYEXT]]
67 ; X86-64-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 16
68 ; X86-64-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[BSWAP]], [[C]](s8)
69 ; X86-64-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[LSHR]](s32)
70 ; X86-64-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY [[TRUNC]](s16)
71 ; X86-64-NEXT: RET 0, implicit [[COPY]](s16)
72 %0:_(s16) = IMPLICIT_DEF
73 %1:_(s16) = G_BSWAP %0
74 %2:_(s16) = COPY %1(s16)