1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=aarch64-apple-ios -global-isel -global-isel-abort=1 | FileCheck %s
define dso_local void @trunc_i16_to_i8(i16 %x, i8* %p) {
; CHECK-LABEL: trunc_i16_to_i8:
; CHECK: ; %bb.0:
; CHECK-NEXT: strh w0, [x1]
; CHECK-NEXT: ret
%t1 = trunc i16 %x to i8
%sh = lshr i16 %x, 8
%t2 = trunc i16 %sh to i8
store i8 %t1, i8* %p, align 1
%p1 = getelementptr inbounds i8, i8* %p, i64 1
store i8 %t2, i8* %p1, align 1
ret void
}
define dso_local void @trunc_i32_to_i8(i32 %x, i8* %p) {
; CHECK-LABEL: trunc_i32_to_i8:
; CHECK: ; %bb.0:
; CHECK-NEXT: str w0, [x1]
; CHECK-NEXT: ret
%t1 = trunc i32 %x to i8
%sh1 = lshr i32 %x, 8
%t2 = trunc i32 %sh1 to i8
%sh2 = lshr i32 %x, 16
%t3 = trunc i32 %sh2 to i8
%sh3 = lshr i32 %x, 24
%t4 = trunc i32 %sh3 to i8
store i8 %t1, i8* %p, align 1
%p1 = getelementptr inbounds i8, i8* %p, i64 1
store i8 %t2, i8* %p1, align 1
%p2 = getelementptr inbounds i8, i8* %p, i64 2
store i8 %t3, i8* %p2, align 1
%p3 = getelementptr inbounds i8, i8* %p, i64 3
store i8 %t4, i8* %p3, align 1
ret void
}
define dso_local void @trunc_i32_to_i16(i32 %x, i16* %p) {
; CHECK-LABEL: trunc_i32_to_i16:
; CHECK: ; %bb.0:
; CHECK-NEXT: str w0, [x1]
; CHECK-NEXT: ret
%t1 = trunc i32 %x to i16
%sh = lshr i32 %x, 16
%t2 = trunc i32 %sh to i16
store i16 %t1, i16* %p, align 2
%p1 = getelementptr inbounds i16, i16* %p, i64 1
store i16 %t2, i16* %p1, align 2
ret void
}
define dso_local void @be_i32_to_i16(i32 %x, i16* %p0) {
; CHECK-LABEL: be_i32_to_i16:
; CHECK: ; %bb.0:
; CHECK-NEXT: ror w8, w0, #16
; CHECK-NEXT: str w8, [x1]
; CHECK-NEXT: ret
%sh1 = lshr i32 %x, 16
%t0 = trunc i32 %x to i16
%t1 = trunc i32 %sh1 to i16
%p1 = getelementptr inbounds i16, i16* %p0, i64 1
store i16 %t0, i16* %p1, align 2
store i16 %t1, i16* %p0, align 2
ret void
}
define dso_local void @be_i32_to_i16_order(i32 %x, i16* %p0) {
; CHECK-LABEL: be_i32_to_i16_order:
; CHECK: ; %bb.0:
; CHECK-NEXT: ror w8, w0, #16
; CHECK-NEXT: str w8, [x1]
; CHECK-NEXT: ret
%sh1 = lshr i32 %x, 16
%t0 = trunc i32 %x to i16
%t1 = trunc i32 %sh1 to i16
%p1 = getelementptr inbounds i16, i16* %p0, i64 1
store i16 %t1, i16* %p0, align 2
store i16 %t0, i16* %p1, align 2
ret void
}
define dso_local void @trunc_i64_to_i8(i64 %x, i8* %p) {
; CHECK-LABEL: trunc_i64_to_i8:
; CHECK: ; %bb.0:
; CHECK-NEXT: str x0, [x1]
; CHECK-NEXT: ret
%t1 = trunc i64 %x to i8
%sh1 = lshr i64 %x, 8
%t2 = trunc i64 %sh1 to i8
%sh2 = lshr i64 %x, 16
%t3 = trunc i64 %sh2 to i8
%sh3 = lshr i64 %x, 24
%t4 = trunc i64 %sh3 to i8
%sh4 = lshr i64 %x, 32
%t5 = trunc i64 %sh4 to i8
%sh5 = lshr i64 %x, 40
%t6 = trunc i64 %sh5 to i8
%sh6 = lshr i64 %x, 48
%t7 = trunc i64 %sh6 to i8
%sh7 = lshr i64 %x, 56
%t8 = trunc i64 %sh7 to i8
store i8 %t1, i8* %p, align 1
%p1 = getelementptr inbounds i8, i8* %p, i64 1
store i8 %t2, i8* %p1, align 1
%p2 = getelementptr inbounds i8, i8* %p, i64 2
store i8 %t3, i8* %p2, align 1
%p3 = getelementptr inbounds i8, i8* %p, i64 3
store i8 %t4, i8* %p3, align 1
%p4 = getelementptr inbounds i8, i8* %p, i64 4
store i8 %t5, i8* %p4, align 1
%p5 = getelementptr inbounds i8, i8* %p, i64 5
store i8 %t6, i8* %p5, align 1
%p6 = getelementptr inbounds i8, i8* %p, i64 6
store i8 %t7, i8* %p6, align 1
%p7 = getelementptr inbounds i8, i8* %p, i64 7
store i8 %t8, i8* %p7, align 1
ret void
}
define dso_local void @trunc_i64_to_i16(i64 %x, i16* %p) {
; CHECK-LABEL: trunc_i64_to_i16:
; CHECK: ; %bb.0:
; CHECK-NEXT: str x0, [x1]
; CHECK-NEXT: ret
%t1 = trunc i64 %x to i16
%sh1 = lshr i64 %x, 16
%t2 = trunc i64 %sh1 to i16
%sh2 = lshr i64 %x, 32
%t3 = trunc i64 %sh2 to i16
%sh3 = lshr i64 %x, 48
%t4 = trunc i64 %sh3 to i16
store i16 %t1, i16* %p, align 2
%p1 = getelementptr inbounds i16, i16* %p, i64 1
store i16 %t2, i16* %p1, align 2
%p2 = getelementptr inbounds i16, i16* %p, i64 2
store i16 %t3, i16* %p2, align 2
%p3 = getelementptr inbounds i16, i16* %p, i64 3
store i16 %t4, i16* %p3, align 2
ret void
}
define dso_local void @trunc_i64_to_i32(i64 %x, i32* %p) {
; CHECK-LABEL: trunc_i64_to_i32:
; CHECK: ; %bb.0:
; CHECK-NEXT: str x0, [x1]
; CHECK-NEXT: ret
%t1 = trunc i64 %x to i32
%sh = lshr i64 %x, 32
%t2 = trunc i64 %sh to i32
store i32 %t1, i32* %p, align 4
%p1 = getelementptr inbounds i32, i32* %p, i64 1
store i32 %t2, i32* %p1, align 4
ret void
}
define dso_local void @be_i64_to_i32(i64 %x, i32* %p0) {
; CHECK-LABEL: be_i64_to_i32:
; CHECK: ; %bb.0:
; CHECK-NEXT: ror x8, x0, #32
; CHECK-NEXT: str x8, [x1]
; CHECK-NEXT: ret
%sh1 = lshr i64 %x, 32
%t0 = trunc i64 %x to i32
%t1 = trunc i64 %sh1 to i32
%p1 = getelementptr inbounds i32, i32* %p0, i64 1
store i32 %t0, i32* %p1, align 4
store i32 %t1, i32* %p0, align 4
ret void
}
define dso_local void @be_i64_to_i32_order(i64 %x, i32* %p0) {
; CHECK-LABEL: be_i64_to_i32_order:
; CHECK: ; %bb.0:
; CHECK-NEXT: ror x8, x0, #32
; CHECK-NEXT: str x8, [x1]
; CHECK-NEXT: ret
%sh1 = lshr i64 %x, 32
%t0 = trunc i64 %x to i32
%t1 = trunc i64 %sh1 to i32
%p1 = getelementptr inbounds i32, i32* %p0, i64 1
store i32 %t1, i32* %p0, align 4
store i32 %t0, i32* %p1, align 4
ret void
}
; Negative tests.
define void @merge_hole(i32 %x, i8* %p) {
; CHECK-LABEL: merge_hole:
; CHECK: ; %bb.0:
; CHECK-NEXT: lsr w8, w0, #16
; CHECK-NEXT: strb w0, [x1]
; CHECK-NEXT: strh w8, [x1, #2]
; CHECK-NEXT: ret
%pcast = bitcast i8* %p to i16*
%p2 = getelementptr inbounds i16, i16* %pcast, i64 1
%x3 = trunc i32 %x to i8
store i8 %x3, i8* %p, align 1
%sh = lshr i32 %x, 16
%x01 = trunc i32 %sh to i16
store i16 %x01, i16* %p2, align 1
ret void
}
define void @merge_hole2(i32 %x, i8* %p) {
; CHECK-LABEL: merge_hole2:
; CHECK: ; %bb.0:
; CHECK-NEXT: lsr w8, w0, #16
; CHECK-NEXT: strb w0, [x1]
; CHECK-NEXT: strh w8, [x1, #2]
; CHECK-NEXT: ret
%pcast = bitcast i8* %p to i16*
%p2 = getelementptr inbounds i16, i16* %pcast, i64 1
%sh = lshr i32 %x, 16
%x01 = trunc i32 %sh to i16
store i16 %x01, i16* %p2, align 1
%x3 = trunc i32 %x to i8
store i8 %x3, i8* %p, align 1
ret void
}
define void @merge_hole3(i32 %x, i8* %p) {
; CHECK-LABEL: merge_hole3:
; CHECK: ; %bb.0:
; CHECK-NEXT: lsr w8, w0, #16
; CHECK-NEXT: strb w0, [x1, #1]
; CHECK-NEXT: strh w8, [x1, #2]
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i8, i8* %p, i64 1
%pcast = bitcast i8* %p to i16*
%p2 = getelementptr inbounds i16, i16* %pcast, i64 1
%x3 = trunc i32 %x to i8
store i8 %x3, i8* %p1, align 1
%sh = lshr i32 %x, 16
%x01 = trunc i32 %sh to i16
store i16 %x01, i16* %p2, align 1
ret void
}
define void @merge_hole4(i32 %x, i8* %p) {
; CHECK-LABEL: merge_hole4:
; CHECK: ; %bb.0:
; CHECK-NEXT: lsr w8, w0, #16
; CHECK-NEXT: strb w0, [x1, #2]
; CHECK-NEXT: strh w8, [x1]
; CHECK-NEXT: ret
%pcast = bitcast i8* %p to i16*
%p2 = getelementptr inbounds i8, i8* %p, i64 2
%x3 = trunc i32 %x to i8
store i8 %x3, i8* %p2, align 1
%sh = lshr i32 %x, 16
%x01 = trunc i32 %sh to i16
store i16 %x01, i16* %pcast, align 1
ret void
}
define dso_local i32 @load_between_stores(i32 %x, i16* %p, i32 *%ptr) {
; CHECK-LABEL: load_between_stores:
; CHECK: ; %bb.0:
; CHECK-NEXT: strh w0, [x1]
; CHECK-NEXT: lsr w9, w0, #16
; CHECK-NEXT: ldr w8, [x2]
; CHECK-NEXT: strh w9, [x1, #2]
; CHECK-NEXT: mov w0, w8
; CHECK-NEXT: ret
%t1 = trunc i32 %x to i16
%sh = lshr i32 %x, 16
%t2 = trunc i32 %sh to i16
store i16 %t1, i16* %p, align 2
%ld = load i32, i32 *%ptr
%p1 = getelementptr inbounds i16, i16* %p, i64 1
store i16 %t2, i16* %p1, align 2
ret i32 %ld
}
define dso_local void @invalid_shift(i16 %x, i8* %p) {
; CHECK-LABEL: invalid_shift:
; CHECK: ; %bb.0:
; CHECK-NEXT: ubfx w8, w0, #4, #12
; CHECK-NEXT: strb w0, [x1]
; CHECK-NEXT: strb w8, [x1, #1]
; CHECK-NEXT: ret
%t1 = trunc i16 %x to i8
%sh = lshr i16 %x, 4
%t2 = trunc i16 %sh to i8
store i8 %t1, i8* %p, align 1
%p1 = getelementptr inbounds i8, i8* %p, i64 1
store i8 %t2, i8* %p1, align 1
ret void
}
define dso_local void @missing_store(i32 %x, i8* %p) {
; CHECK-LABEL: missing_store:
; CHECK: ; %bb.0:
; CHECK-NEXT: lsr w8, w0, #8
; CHECK-NEXT: lsr w9, w0, #24
; CHECK-NEXT: strb w0, [x1]
; CHECK-NEXT: strb w8, [x1, #1]
; CHECK-NEXT: strb w9, [x1, #3]
; CHECK-NEXT: ret
%t1 = trunc i32 %x to i8
%sh1 = lshr i32 %x, 8
%t2 = trunc i32 %sh1 to i8
%sh3 = lshr i32 %x, 24
%t4 = trunc i32 %sh3 to i8
store i8 %t1, i8* %p, align 1
%p1 = getelementptr inbounds i8, i8* %p, i64 1
store i8 %t2, i8* %p1, align 1
%p3 = getelementptr inbounds i8, i8* %p, i64 3
store i8 %t4, i8* %p3, align 1
ret void
}
define dso_local void @different_base_reg(i16 %x, i8* %p, i8 *%p2) {
; CHECK-LABEL: different_base_reg:
; CHECK: ; %bb.0:
; CHECK-NEXT: ubfx w8, w0, #8, #8
; CHECK-NEXT: strb w0, [x1]
; CHECK-NEXT: strb w8, [x2, #1]
; CHECK-NEXT: ret
%t1 = trunc i16 %x to i8
%sh = lshr i16 %x, 8
%t2 = trunc i16 %sh to i8
store i8 %t1, i8* %p, align 1
%p1 = getelementptr inbounds i8, i8* %p2, i64 1
store i8 %t2, i8* %p1, align 1
ret void
}
define dso_local void @second_store_is_volatile(i16 %x, i8* %p) {
; CHECK-LABEL: second_store_is_volatile:
; CHECK: ; %bb.0:
; CHECK-NEXT: ubfx w8, w0, #8, #8
; CHECK-NEXT: strb w0, [x1]
; CHECK-NEXT: strb w8, [x1, #1]
; CHECK-NEXT: ret
%t1 = trunc i16 %x to i8
%sh = lshr i16 %x, 8
%t2 = trunc i16 %sh to i8
store volatile i8 %t1, i8* %p, align 1
%p1 = getelementptr inbounds i8, i8* %p, i64 1
store i8 %t2, i8* %p1, align 1
ret void
}
|