1 ; RUN: llc -verify-machineinstrs -o - %s -mtriple=aarch64-linux-gnu | FileCheck %s
2 ; RUN: llc -global-isel -global-isel-abort=2 -pass-remarks-missed=gisel* -verify-machineinstrs -o - %s -mtriple=aarch64-linux-gnu | FileCheck %s --check-prefixes=FALLBACK,GISEL
7 ; FALLBACK-NOT: remark{{.*}}rev_i32
8 define void @rev_i32() {
9 ; CHECK-LABEL: rev_i32:
10 ; GISEL-LABEL: rev_i32:
11 %val0_tmp = load i32, i32* @var32
12 %val1_tmp = call i32 @llvm.bswap.i32(i32 %val0_tmp)
13 ; CHECK: rev {{w[0-9]+}}, {{w[0-9]+}}
14 ; GISEL: rev {{w[0-9]+}}, {{w[0-9]+}}
15 store volatile i32 %val1_tmp, i32* @var32
19 ; FALLBACK-NOT: remark{{.*}}rev_i64
20 define void @rev_i64() {
21 ; CHECK-LABEL: rev_i64:
22 ; GISEL-LABEL: rev_i64:
23 %val0_tmp = load i64, i64* @var64
24 %val1_tmp = call i64 @llvm.bswap.i64(i64 %val0_tmp)
25 ; CHECK: rev {{x[0-9]+}}, {{x[0-9]+}}
26 ; GISEL: rev {{x[0-9]+}}, {{x[0-9]+}}
27 store volatile i64 %val1_tmp, i64* @var64
31 define void @rev32_i64() {
32 ; CHECK-LABEL: rev32_i64:
33 %val0_tmp = load i64, i64* @var64
34 %val1_tmp = shl i64 %val0_tmp, 32
35 %val5_tmp = sub i64 64, 32
36 %val2_tmp = lshr i64 %val0_tmp, %val5_tmp
37 %val3_tmp = or i64 %val1_tmp, %val2_tmp
38 %val4_tmp = call i64 @llvm.bswap.i64(i64 %val3_tmp)
39 ; CHECK: rev32 {{x[0-9]+}}, {{x[0-9]+}}
40 store volatile i64 %val4_tmp, i64* @var64
44 define void @rev16_i32() {
45 ; CHECK-LABEL: rev16_i32:
46 %val0_tmp = load i32, i32* @var32
47 %val1_tmp = shl i32 %val0_tmp, 16
48 %val2_tmp = lshr i32 %val0_tmp, 16
49 %val3_tmp = or i32 %val1_tmp, %val2_tmp
50 %val4_tmp = call i32 @llvm.bswap.i32(i32 %val3_tmp)
51 ; CHECK: rev16 {{w[0-9]+}}, {{w[0-9]+}}
52 store volatile i32 %val4_tmp, i32* @var32
56 define void @clz_zerodef_i32() {
57 ; CHECK-LABEL: clz_zerodef_i32:
58 %val0_tmp = load i32, i32* @var32
59 %val4_tmp = call i32 @llvm.ctlz.i32(i32 %val0_tmp, i1 0)
60 ; CHECK: clz {{w[0-9]+}}, {{w[0-9]+}}
61 store volatile i32 %val4_tmp, i32* @var32
65 define void @clz_zerodef_i64() {
66 ; CHECK-LABEL: clz_zerodef_i64:
67 %val0_tmp = load i64, i64* @var64
68 %val4_tmp = call i64 @llvm.ctlz.i64(i64 %val0_tmp, i1 0)
69 ; CHECK: clz {{x[0-9]+}}, {{x[0-9]+}}
70 store volatile i64 %val4_tmp, i64* @var64
74 define void @clz_zeroundef_i32() {
75 ; CHECK-LABEL: clz_zeroundef_i32:
76 %val0_tmp = load i32, i32* @var32
77 %val4_tmp = call i32 @llvm.ctlz.i32(i32 %val0_tmp, i1 1)
78 ; CHECK: clz {{w[0-9]+}}, {{w[0-9]+}}
79 store volatile i32 %val4_tmp, i32* @var32
83 define void @clz_zeroundef_i64() {
84 ; CHECK-LABEL: clz_zeroundef_i64:
85 %val0_tmp = load i64, i64* @var64
86 %val4_tmp = call i64 @llvm.ctlz.i64(i64 %val0_tmp, i1 1)
87 ; CHECK: clz {{x[0-9]+}}, {{x[0-9]+}}
88 store volatile i64 %val4_tmp, i64* @var64
92 define void @cttz_zerodef_i32() {
93 ; CHECK-LABEL: cttz_zerodef_i32:
94 %val0_tmp = load i32, i32* @var32
95 %val4_tmp = call i32 @llvm.cttz.i32(i32 %val0_tmp, i1 0)
96 ; CHECK: rbit [[REVERSED:w[0-9]+]], {{w[0-9]+}}
97 ; CHECK: clz {{w[0-9]+}}, [[REVERSED]]
98 store volatile i32 %val4_tmp, i32* @var32
102 define void @cttz_zerodef_i64() {
103 ; CHECK-LABEL: cttz_zerodef_i64:
104 %val0_tmp = load i64, i64* @var64
105 %val4_tmp = call i64 @llvm.cttz.i64(i64 %val0_tmp, i1 0)
106 ; CHECK: rbit [[REVERSED:x[0-9]+]], {{x[0-9]+}}
107 ; CHECK: clz {{x[0-9]+}}, [[REVERSED]]
108 store volatile i64 %val4_tmp, i64* @var64
112 define void @cttz_zeroundef_i32() {
113 ; CHECK-LABEL: cttz_zeroundef_i32:
114 %val0_tmp = load i32, i32* @var32
115 %val4_tmp = call i32 @llvm.cttz.i32(i32 %val0_tmp, i1 1)
116 ; CHECK: rbit [[REVERSED:w[0-9]+]], {{w[0-9]+}}
117 ; CHECK: clz {{w[0-9]+}}, [[REVERSED]]
118 store volatile i32 %val4_tmp, i32* @var32
122 define void @cttz_zeroundef_i64() {
123 ; CHECK-LABEL: cttz_zeroundef_i64:
124 %val0_tmp = load i64, i64* @var64
125 %val4_tmp = call i64 @llvm.cttz.i64(i64 %val0_tmp, i1 1)
126 ; CHECK: rbit [[REVERSED:x[0-9]+]], {{x[0-9]+}}
127 ; CHECK: clz {{x[0-9]+}}, [[REVERSED]]
128 store volatile i64 %val4_tmp, i64* @var64
132 ; These two are just compilation tests really: the operation's set to Expand in
134 define void @ctpop_i32() {
135 ; CHECK-LABEL: ctpop_i32:
136 %val0_tmp = load i32, i32* @var32
137 %val4_tmp = call i32 @llvm.ctpop.i32(i32 %val0_tmp)
138 store volatile i32 %val4_tmp, i32* @var32
142 define void @ctpop_i64() {
143 ; CHECK-LABEL: ctpop_i64:
144 %val0_tmp = load i64, i64* @var64
145 %val4_tmp = call i64 @llvm.ctpop.i64(i64 %val0_tmp)
146 store volatile i64 %val4_tmp, i64* @var64
151 declare i32 @llvm.bswap.i32(i32)
152 declare i64 @llvm.bswap.i64(i64)
153 declare i32 @llvm.ctlz.i32 (i32, i1)
154 declare i64 @llvm.ctlz.i64 (i64, i1)
155 declare i32 @llvm.cttz.i32 (i32, i1)
156 declare i64 @llvm.cttz.i64 (i64, i1)
157 declare i32 @llvm.ctpop.i32 (i32)
158 declare i64 @llvm.ctpop.i64 (i64)