1 ; RUN: llc -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s
4 ; CHECK: sbfx {{x[0-9]+}}, x0, #23, #9
5 define i64 @test1(i32 %a) {
7 %ext = sext i32 %tmp to i64
13 ; CHECK: sbfx w0, w0, #23, #8
14 define signext i8 @test2(i32 %a) {
15 %tmp = ashr i32 %a, 23
16 %res = trunc i32 %tmp to i8
21 ; CHECK: sbfx w0, w0, #23, #8
22 define signext i8 @test3(i32 %a) {
23 %tmp = lshr i32 %a, 23
24 %res = trunc i32 %tmp to i8
29 ; CHECK: sbfx w0, w0, #15, #16
30 define signext i16 @test4(i32 %a) {
31 %tmp = lshr i32 %a, 15
32 %res = trunc i32 %tmp to i16
37 ; CHECK: sbfx w0, w0, #16, #8
38 define signext i8 @test5(i64 %a) {
39 %tmp = lshr i64 %a, 16
40 %res = trunc i64 %tmp to i8
45 ; CHECK: sbfx x0, x0, #30, #8
46 define signext i8 @test6(i64 %a) {
47 %tmp = lshr i64 %a, 30
48 %res = trunc i64 %tmp to i8
53 ; CHECK: sbfx x0, x0, #23, #16
54 define signext i16 @test7(i64 %a) {
55 %tmp = lshr i64 %a, 23
56 %res = trunc i64 %tmp to i16
61 ; CHECK: asr w0, w0, #25
62 define signext i8 @test8(i32 %a) {
63 %tmp = ashr i32 %a, 25
64 %res = trunc i32 %tmp to i8
69 ; CHECK: lsr w0, w0, #25
70 define signext i8 @test9(i32 %a) {
71 %tmp = lshr i32 %a, 25
72 %res = trunc i32 %tmp to i8
76 ; CHECK-LABEL: @test10
77 ; CHECK: lsr x0, x0, #49
78 define signext i16 @test10(i64 %a) {
79 %tmp = lshr i64 %a, 49
80 %res = trunc i64 %tmp to i16
84 ; SHR with multiple uses is fine as SXTH and SBFX are both aliases of SBFM.
85 ; However, allowing the transformation means the SHR and SBFX can execute in
88 ; CHECK-LABEL: @test11
89 ; CHECK: lsr x1, x0, #23
90 ; CHECK: sbfx x0, x0, #23, #16
91 define void @test11(i64 %a) {
92 %tmp = lshr i64 %a, 23
93 %res = trunc i64 %tmp to i16
94 call void @use(i16 %res, i64 %tmp)
98 declare void @use(i16 signext, i64)
100 ; CHECK-LABEL: test_complex_node:
101 ; CHECK: ldr d0, [x0], #8
102 ; CHECK: ubfx x[[VAL:[0-9]+]], x0, #5, #27
103 ; CHECK: str w[[VAL]], [x2]
104 define <2 x i32> @test_complex_node(<2 x i32>* %addr, <2 x i32>** %addr2, i32* %bf ) {
105 %vec = load <2 x i32>, <2 x i32>* %addr
107 %vec.next = getelementptr <2 x i32>, <2 x i32>* %addr, i32 1
108 store <2 x i32>* %vec.next, <2 x i32>** %addr2
109 %lo = ptrtoint <2 x i32>* %vec.next to i32
111 %val = lshr i32 %lo, 5
112 store i32 %val, i32* %bf