1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-apple-darwin | FileCheck %s
4 declare i16 @llvm.bswap.i16(i16)
5 declare i32 @llvm.bswap.i32(i32)
6 declare i64 @llvm.bswap.i64(i64)
8 define i1 @test1(i16 %arg) {
11 ; CHECK-NEXT: mov w0, #1
14 %b = call i16 @llvm.bswap.i16(i16 %a)
15 %and = and i16 %b, 256
16 %res = icmp eq i16 %and, 256
20 define i1 @test2(i16 %arg) {
23 ; CHECK-NEXT: mov w0, #1
26 %b = call i16 @llvm.bswap.i16(i16 %a)
27 %and = and i16 %b, 256
28 %res = icmp eq i16 %and, 256
32 define i1 @test3(i16 %arg) {
35 ; CHECK-NEXT: mov w0, #1
38 %b = call i16 @llvm.bswap.i16(i16 %a)
40 %res = icmp eq i16 %and, 1
44 define i1 @test4(i32 %arg) {
47 ; CHECK-NEXT: mov w0, #1
49 %a = or i32 %arg, 2147483647 ; i32_MAX
50 %b = call i32 @llvm.bswap.i32(i32 %a)
51 %and = and i32 %b, 127
52 %res = icmp eq i32 %and, 127
56 define i8 @demand_one_byte0(i32 %x) {
57 ; CHECK-LABEL: demand_one_byte0:
59 ; CHECK-NEXT: rev w0, w0
61 %b = call i32 @llvm.bswap.i32(i32 %x)
62 %r = trunc i32 %b to i8
66 define i32 @demand_one_byte1(i32 %x) {
67 ; CHECK-LABEL: demand_one_byte1:
69 ; CHECK-NEXT: lsr w8, w0, #8
70 ; CHECK-NEXT: and w0, w8, #0xff00
72 %b = call i32 @llvm.bswap.i32(i32 %x)
73 %r = and i32 %b, 65280 ; 0x0000ff00
77 define i32 @demand_one_byte2(i32 %x) {
78 ; CHECK-LABEL: demand_one_byte2:
80 ; CHECK-NEXT: lsl w8, w0, #8
81 ; CHECK-NEXT: orr w0, w8, #0xff00ffff
83 %b = call i32 @llvm.bswap.i32(i32 %x)
84 %r = or i32 %b, 4278255615 ; 0xff00ffff
88 define i64 @demand_one_byte3(i64 %x) {
89 ; CHECK-LABEL: demand_one_byte3:
91 ; CHECK-NEXT: and x0, x0, #0xff
93 %b = call i64 @llvm.bswap.i64(i64 %x)
98 define void @demand_one_loaded_byte(ptr %xp, ptr %yp) {
99 ; CHECK-LABEL: demand_one_loaded_byte:
101 ; CHECK-NEXT: ldrb w8, [x0, #4]
102 ; CHECK-NEXT: strb w8, [x1]
104 %x = load i64, ptr %xp, align 8
105 %x_zzzz7654 = lshr i64 %x, 32
106 %x_z7654zzz = shl nuw nsw i64 %x_zzzz7654, 24
107 %x_4zzz = trunc i64 %x_z7654zzz to i32
108 %y = load i32, ptr %yp, align 4
109 %y_321z = and i32 %y, -256
110 %x_zzz4 = call i32 @llvm.bswap.i32(i32 %x_4zzz)
111 %r = or i32 %x_zzz4, %y_321z
112 store i32 %r, ptr %yp, align 4