1; RUN: llc < %s -mtriple=aarch64-apple-darwin  | FileCheck %s
2
3declare i16 @llvm.bswap.i16(i16)
4declare i32 @llvm.bswap.i32(i32)
5
6; CHECK-LABEL: @test1
7; CHECK: mov w0, #1
8define i1 @test1(i16 %arg) {
9  %a = or i16 %arg, 511
10  %b = call i16 @llvm.bswap.i16(i16 %a)
11  %and = and i16 %b, 256
12  %res = icmp eq i16 %and, 256
13  ret i1 %res
14}
15
16; CHECK-LABEL: @test2
17; CHECK: mov w0, #1
18define i1 @test2(i16 %arg) {
19  %a = or i16 %arg, 1
20  %b = call i16 @llvm.bswap.i16(i16 %a)
21  %and = and i16 %b, 256
22  %res = icmp eq i16 %and, 256
23  ret i1 %res
24}
25
26; CHECK-LABEL: @test3
27; CHECK: mov w0, #1
28define i1 @test3(i16 %arg) {
29  %a = or i16 %arg, 256
30  %b = call i16 @llvm.bswap.i16(i16 %a)
31  %and = and i16 %b, 1
32  %res = icmp eq i16 %and, 1
33  ret i1 %res
34}
35
36; CHECK-LABEL: @test4
37; CHECK: mov w0, #1
38define i1 @test4(i32 %arg) {
39  %a = or i32 %arg, 2147483647  ; i32_MAX
40  %b = call i32 @llvm.bswap.i32(i32 %a)
41  %and = and i32 %b, 127
42  %res = icmp eq i32 %and, 127
43  ret i1 %res
44}
45