1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -o - -verify-machineinstrs -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=CHECK,GISEL
3 ; RUN: llc < %s -o - -verify-machineinstrs -global-isel=0 | FileCheck %s --check-prefixes=CHECK,SDAG
5 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
6 target triple = "arm64-apple-ios14.5.0"
8 define i32 @bfi_w_31(i32 %in1, i32 %in2) {
9 ; CHECK-LABEL: bfi_w_31:
10 ; CHECK: ; %bb.0: ; %bb
11 ; CHECK-NEXT: bfi w1, w0, #31, #1
12 ; CHECK-NEXT: mov w0, w1
15 %tmp3 = shl i32 %in1, 31
16 %tmp4 = and i32 %in2, 2147483647
17 %out = or i32 %tmp3, %tmp4
21 define i32 @bfi_w_8(i32 %in1, i32 %in2) {
22 ; CHECK-LABEL: bfi_w_8:
23 ; CHECK: ; %bb.0: ; %bb
24 ; CHECK-NEXT: bfi w1, w0, #8, #24
25 ; CHECK-NEXT: mov w0, w1
28 %tmp3 = shl i32 %in1, 8
29 %tmp4 = and i32 %in2, 255
30 %out = or i32 %tmp3, %tmp4
34 define i32 @bfi_w_1(i32 %in1, i32 %in2) {
35 ; CHECK-LABEL: bfi_w_1:
36 ; CHECK: ; %bb.0: ; %bb
37 ; CHECK-NEXT: bfi w1, w0, #1, #31
38 ; CHECK-NEXT: mov w0, w1
41 %tmp3 = shl i32 %in1, 1
42 %tmp4 = and i32 %in2, 1
43 %out = or i32 %tmp3, %tmp4
47 define i64 @bfi_x_63(i64 %in1, i64 %in2) {
48 ; CHECK-LABEL: bfi_x_63:
49 ; CHECK: ; %bb.0: ; %bb
50 ; CHECK-NEXT: bfi x1, x0, #63, #1
51 ; CHECK-NEXT: mov x0, x1
54 %tmp3 = shl i64 %in1, 63
55 %tmp4 = and i64 %in2, 9223372036854775807
56 %out = or i64 %tmp3, %tmp4
60 define i64 @bfi_x_31(i64 %in1, i64 %in2) {
61 ; CHECK-LABEL: bfi_x_31:
62 ; CHECK: ; %bb.0: ; %bb
63 ; CHECK-NEXT: bfi x1, x0, #31, #33
64 ; CHECK-NEXT: mov x0, x1
67 %tmp3 = shl i64 %in1, 31
68 %tmp4 = and i64 %in2, 2147483647
69 %out = or i64 %tmp3, %tmp4
73 define i64 @bfi_x_8(i64 %in1, i64 %in2) {
74 ; CHECK-LABEL: bfi_x_8:
75 ; CHECK: ; %bb.0: ; %bb
76 ; CHECK-NEXT: bfi x1, x0, #8, #56
77 ; CHECK-NEXT: mov x0, x1
80 %tmp3 = shl i64 %in1, 8
81 %tmp4 = and i64 %in2, 255
82 %out = or i64 %tmp3, %tmp4
86 define i64 @bfi_x_1(i64 %in1, i64 %in2) {
87 ; CHECK-LABEL: bfi_x_1:
88 ; CHECK: ; %bb.0: ; %bb
89 ; CHECK-NEXT: bfi x1, x0, #1, #63
90 ; CHECK-NEXT: mov x0, x1
93 %tmp3 = shl i64 %in1, 1
94 %tmp4 = and i64 %in2, 1
95 %out = or i64 %tmp3, %tmp4
99 define i64 @bfi_x_1_swapped(i64 %in1, i64 %in2) {
100 ; CHECK-LABEL: bfi_x_1_swapped:
101 ; CHECK: ; %bb.0: ; %bb
102 ; CHECK-NEXT: bfi x1, x0, #1, #63
103 ; CHECK-NEXT: mov x0, x1
106 %tmp3 = shl i64 %in1, 1
107 %tmp4 = and i64 %in2, 1
108 %out = or i64 %tmp4, %tmp3
112 define i64 @extra_use1(i64 %in1, i64 %in2, ptr %p) {
113 ; GISEL-LABEL: extra_use1:
114 ; GISEL: ; %bb.0: ; %bb
115 ; GISEL-NEXT: lsl x8, x0, #1
116 ; GISEL-NEXT: and x9, x1, #0x1
117 ; GISEL-NEXT: orr x0, x8, x9
118 ; GISEL-NEXT: str x8, [x2]
121 ; SDAG-LABEL: extra_use1:
122 ; SDAG: ; %bb.0: ; %bb
123 ; SDAG-NEXT: bfi x1, x0, #1, #63
124 ; SDAG-NEXT: lsl x8, x0, #1
125 ; SDAG-NEXT: mov x0, x1
126 ; SDAG-NEXT: str x8, [x2]
129 %tmp3 = shl i64 %in1, 1
130 %tmp4 = and i64 %in2, 1
131 %out = or i64 %tmp3, %tmp4
132 store i64 %tmp3, ptr %p
136 define i64 @extra_use2(i64 %in1, i64 %in2, ptr %p) {
137 ; GISEL-LABEL: extra_use2:
138 ; GISEL: ; %bb.0: ; %bb
139 ; GISEL-NEXT: and x8, x1, #0x1
140 ; GISEL-NEXT: orr x0, x8, x0, lsl #1
141 ; GISEL-NEXT: str x8, [x2]
144 ; SDAG-LABEL: extra_use2:
145 ; SDAG: ; %bb.0: ; %bb
146 ; SDAG-NEXT: and x8, x1, #0x1
147 ; SDAG-NEXT: bfi x1, x0, #1, #63
148 ; SDAG-NEXT: str x8, [x2]
149 ; SDAG-NEXT: mov x0, x1
152 %tmp3 = shl i64 %in1, 1
153 %tmp4 = and i64 %in2, 1
154 %out = or i64 %tmp3, %tmp4
155 store i64 %tmp4, ptr %p