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 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=arm64-eabi -verify-machineinstrs | FileCheck %s
define i32 @ldp_int(i32* %p) nounwind {
; CHECK-LABEL: ldp_int:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp w8, w9, [x0]
; CHECK-NEXT: add w0, w9, w8
; CHECK-NEXT: ret
%tmp = load i32, i32* %p, align 4
%add.ptr = getelementptr inbounds i32, i32* %p, i64 1
%tmp1 = load i32, i32* %add.ptr, align 4
%add = add nsw i32 %tmp1, %tmp
ret i32 %add
}
define i64 @ldp_sext_int(i32* %p) nounwind {
; CHECK-LABEL: ldp_sext_int:
; CHECK: // %bb.0:
; CHECK-NEXT: ldpsw x8, x9, [x0]
; CHECK-NEXT: add x0, x9, x8
; CHECK-NEXT: ret
%tmp = load i32, i32* %p, align 4
%add.ptr = getelementptr inbounds i32, i32* %p, i64 1
%tmp1 = load i32, i32* %add.ptr, align 4
%sexttmp = sext i32 %tmp to i64
%sexttmp1 = sext i32 %tmp1 to i64
%add = add nsw i64 %sexttmp1, %sexttmp
ret i64 %add
}
define i64 @ldp_half_sext_res0_int(i32* %p) nounwind {
; CHECK-LABEL: ldp_half_sext_res0_int:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp w8, w9, [x0]
; CHECK-NEXT: // kill: def $w8 killed $w8 def $x8
; CHECK-NEXT: sxtw x8, w8
; CHECK-NEXT: add x0, x9, x8
; CHECK-NEXT: ret
%tmp = load i32, i32* %p, align 4
%add.ptr = getelementptr inbounds i32, i32* %p, i64 1
%tmp1 = load i32, i32* %add.ptr, align 4
%sexttmp = sext i32 %tmp to i64
%sexttmp1 = zext i32 %tmp1 to i64
%add = add nsw i64 %sexttmp1, %sexttmp
ret i64 %add
}
define i64 @ldp_half_sext_res1_int(i32* %p) nounwind {
; CHECK-LABEL: ldp_half_sext_res1_int:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp w8, w9, [x0]
; CHECK-NEXT: // kill: def $w9 killed $w9 def $x9
; CHECK-NEXT: sxtw x9, w9
; CHECK-NEXT: add x0, x9, x8
; CHECK-NEXT: ret
%tmp = load i32, i32* %p, align 4
%add.ptr = getelementptr inbounds i32, i32* %p, i64 1
%tmp1 = load i32, i32* %add.ptr, align 4
%sexttmp = zext i32 %tmp to i64
%sexttmp1 = sext i32 %tmp1 to i64
%add = add nsw i64 %sexttmp1, %sexttmp
ret i64 %add
}
define i64 @ldp_long(i64* %p) nounwind {
; CHECK-LABEL: ldp_long:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp x8, x9, [x0]
; CHECK-NEXT: add x0, x9, x8
; CHECK-NEXT: ret
%tmp = load i64, i64* %p, align 8
%add.ptr = getelementptr inbounds i64, i64* %p, i64 1
%tmp1 = load i64, i64* %add.ptr, align 8
%add = add nsw i64 %tmp1, %tmp
ret i64 %add
}
define float @ldp_float(float* %p) nounwind {
; CHECK-LABEL: ldp_float:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp s0, s1, [x0]
; CHECK-NEXT: fadd s0, s0, s1
; CHECK-NEXT: ret
%tmp = load float, float* %p, align 4
%add.ptr = getelementptr inbounds float, float* %p, i64 1
%tmp1 = load float, float* %add.ptr, align 4
%add = fadd float %tmp, %tmp1
ret float %add
}
define double @ldp_double(double* %p) nounwind {
; CHECK-LABEL: ldp_double:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp d0, d1, [x0]
; CHECK-NEXT: fadd d0, d0, d1
; CHECK-NEXT: ret
%tmp = load double, double* %p, align 8
%add.ptr = getelementptr inbounds double, double* %p, i64 1
%tmp1 = load double, double* %add.ptr, align 8
%add = fadd double %tmp, %tmp1
ret double %add
}
define <2 x double> @ldp_doublex2(<2 x double>* %p) nounwind {
; CHECK-LABEL: ldp_doublex2:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp q0, q1, [x0]
; CHECK-NEXT: fadd v0.2d, v0.2d, v1.2d
; CHECK-NEXT: ret
%tmp = load <2 x double>, <2 x double>* %p, align 16
%add.ptr = getelementptr inbounds <2 x double>, <2 x double>* %p, i64 1
%tmp1 = load <2 x double>, <2 x double>* %add.ptr, align 16
%add = fadd <2 x double> %tmp, %tmp1
ret <2 x double> %add
}
; Test the load/store optimizer---combine ldurs into a ldp, if appropriate
define i32 @ldur_int(i32* %a) nounwind {
; CHECK-LABEL: ldur_int:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp w9, w8, [x0, #-8]
; CHECK-NEXT: add w0, w8, w9
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i32, i32* %a, i32 -1
%tmp1 = load i32, i32* %p1, align 2
%p2 = getelementptr inbounds i32, i32* %a, i32 -2
%tmp2 = load i32, i32* %p2, align 2
%tmp3 = add i32 %tmp1, %tmp2
ret i32 %tmp3
}
define i64 @ldur_sext_int(i32* %a) nounwind {
; CHECK-LABEL: ldur_sext_int:
; CHECK: // %bb.0:
; CHECK-NEXT: ldpsw x9, x8, [x0, #-8]
; CHECK-NEXT: add x0, x8, x9
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i32, i32* %a, i32 -1
%tmp1 = load i32, i32* %p1, align 2
%p2 = getelementptr inbounds i32, i32* %a, i32 -2
%tmp2 = load i32, i32* %p2, align 2
%sexttmp1 = sext i32 %tmp1 to i64
%sexttmp2 = sext i32 %tmp2 to i64
%tmp3 = add i64 %sexttmp1, %sexttmp2
ret i64 %tmp3
}
define i64 @ldur_half_sext_int_res0(i32* %a) nounwind {
; CHECK-LABEL: ldur_half_sext_int_res0:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp w9, w8, [x0, #-8]
; CHECK-NEXT: // kill: def $w9 killed $w9 def $x9
; CHECK-NEXT: sxtw x9, w9
; CHECK-NEXT: add x0, x8, x9
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i32, i32* %a, i32 -1
%tmp1 = load i32, i32* %p1, align 2
%p2 = getelementptr inbounds i32, i32* %a, i32 -2
%tmp2 = load i32, i32* %p2, align 2
%sexttmp1 = zext i32 %tmp1 to i64
%sexttmp2 = sext i32 %tmp2 to i64
%tmp3 = add i64 %sexttmp1, %sexttmp2
ret i64 %tmp3
}
define i64 @ldur_half_sext_int_res1(i32* %a) nounwind {
; CHECK-LABEL: ldur_half_sext_int_res1:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp w9, w8, [x0, #-8]
; CHECK-NEXT: // kill: def $w8 killed $w8 def $x8
; CHECK-NEXT: sxtw x8, w8
; CHECK-NEXT: add x0, x8, x9
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i32, i32* %a, i32 -1
%tmp1 = load i32, i32* %p1, align 2
%p2 = getelementptr inbounds i32, i32* %a, i32 -2
%tmp2 = load i32, i32* %p2, align 2
%sexttmp1 = sext i32 %tmp1 to i64
%sexttmp2 = zext i32 %tmp2 to i64
%tmp3 = add i64 %sexttmp1, %sexttmp2
ret i64 %tmp3
}
define i64 @ldur_long(i64* %a) nounwind ssp {
; CHECK-LABEL: ldur_long:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp x9, x8, [x0, #-16]
; CHECK-NEXT: add x0, x8, x9
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i64, i64* %a, i64 -1
%tmp1 = load i64, i64* %p1, align 2
%p2 = getelementptr inbounds i64, i64* %a, i64 -2
%tmp2 = load i64, i64* %p2, align 2
%tmp3 = add i64 %tmp1, %tmp2
ret i64 %tmp3
}
define float @ldur_float(float* %a) {
; CHECK-LABEL: ldur_float:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp s1, s0, [x0, #-8]
; CHECK-NEXT: fadd s0, s0, s1
; CHECK-NEXT: ret
%p1 = getelementptr inbounds float, float* %a, i64 -1
%tmp1 = load float, float* %p1, align 2
%p2 = getelementptr inbounds float, float* %a, i64 -2
%tmp2 = load float, float* %p2, align 2
%tmp3 = fadd float %tmp1, %tmp2
ret float %tmp3
}
define double @ldur_double(double* %a) {
; CHECK-LABEL: ldur_double:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp d1, d0, [x0, #-16]
; CHECK-NEXT: fadd d0, d0, d1
; CHECK-NEXT: ret
%p1 = getelementptr inbounds double, double* %a, i64 -1
%tmp1 = load double, double* %p1, align 2
%p2 = getelementptr inbounds double, double* %a, i64 -2
%tmp2 = load double, double* %p2, align 2
%tmp3 = fadd double %tmp1, %tmp2
ret double %tmp3
}
define <2 x double> @ldur_doublex2(<2 x double>* %a) {
; CHECK-LABEL: ldur_doublex2:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp q1, q0, [x0, #-32]
; CHECK-NEXT: fadd v0.2d, v0.2d, v1.2d
; CHECK-NEXT: ret
%p1 = getelementptr inbounds <2 x double>, <2 x double>* %a, i64 -1
%tmp1 = load <2 x double>, <2 x double>* %p1, align 2
%p2 = getelementptr inbounds <2 x double>, <2 x double>* %a, i64 -2
%tmp2 = load <2 x double>, <2 x double>* %p2, align 2
%tmp3 = fadd <2 x double> %tmp1, %tmp2
ret <2 x double> %tmp3
}
; Now check some boundary conditions
define i64 @pairUpBarelyIn(i64* %a) nounwind ssp {
; CHECK-LABEL: pairUpBarelyIn:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp x9, x8, [x0, #-256]
; CHECK-NEXT: add x0, x8, x9
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i64, i64* %a, i64 -31
%tmp1 = load i64, i64* %p1, align 2
%p2 = getelementptr inbounds i64, i64* %a, i64 -32
%tmp2 = load i64, i64* %p2, align 2
%tmp3 = add i64 %tmp1, %tmp2
ret i64 %tmp3
}
define i64 @pairUpBarelyInSext(i32* %a) nounwind ssp {
; CHECK-LABEL: pairUpBarelyInSext:
; CHECK: // %bb.0:
; CHECK-NEXT: ldpsw x9, x8, [x0, #-256]
; CHECK-NEXT: add x0, x8, x9
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i32, i32* %a, i64 -63
%tmp1 = load i32, i32* %p1, align 2
%p2 = getelementptr inbounds i32, i32* %a, i64 -64
%tmp2 = load i32, i32* %p2, align 2
%sexttmp1 = sext i32 %tmp1 to i64
%sexttmp2 = sext i32 %tmp2 to i64
%tmp3 = add i64 %sexttmp1, %sexttmp2
ret i64 %tmp3
}
define i64 @pairUpBarelyInHalfSextRes0(i32* %a) nounwind ssp {
; CHECK-LABEL: pairUpBarelyInHalfSextRes0:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp w9, w8, [x0, #-256]
; CHECK-NEXT: // kill: def $w9 killed $w9 def $x9
; CHECK-NEXT: sxtw x9, w9
; CHECK-NEXT: add x0, x8, x9
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i32, i32* %a, i64 -63
%tmp1 = load i32, i32* %p1, align 2
%p2 = getelementptr inbounds i32, i32* %a, i64 -64
%tmp2 = load i32, i32* %p2, align 2
%sexttmp1 = zext i32 %tmp1 to i64
%sexttmp2 = sext i32 %tmp2 to i64
%tmp3 = add i64 %sexttmp1, %sexttmp2
ret i64 %tmp3
}
define i64 @pairUpBarelyInHalfSextRes1(i32* %a) nounwind ssp {
; CHECK-LABEL: pairUpBarelyInHalfSextRes1:
; CHECK: // %bb.0:
; CHECK-NEXT: ldp w9, w8, [x0, #-256]
; CHECK-NEXT: // kill: def $w8 killed $w8 def $x8
; CHECK-NEXT: sxtw x8, w8
; CHECK-NEXT: add x0, x8, x9
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i32, i32* %a, i64 -63
%tmp1 = load i32, i32* %p1, align 2
%p2 = getelementptr inbounds i32, i32* %a, i64 -64
%tmp2 = load i32, i32* %p2, align 2
%sexttmp1 = sext i32 %tmp1 to i64
%sexttmp2 = zext i32 %tmp2 to i64
%tmp3 = add i64 %sexttmp1, %sexttmp2
ret i64 %tmp3
}
define i64 @pairUpBarelyOut(i64* %a) nounwind ssp {
; Don't be fragile about which loads or manipulations of the base register
; are used---just check that there isn't an ldp before the add
; CHECK-LABEL: pairUpBarelyOut:
; CHECK: // %bb.0:
; CHECK-NEXT: sub x8, x0, #264
; CHECK-NEXT: ldur x9, [x0, #-256]
; CHECK-NEXT: ldr x8, [x8]
; CHECK-NEXT: add x0, x9, x8
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i64, i64* %a, i64 -32
%tmp1 = load i64, i64* %p1, align 2
%p2 = getelementptr inbounds i64, i64* %a, i64 -33
%tmp2 = load i64, i64* %p2, align 2
%tmp3 = add i64 %tmp1, %tmp2
ret i64 %tmp3
}
define i64 @pairUpBarelyOutSext(i32* %a) nounwind ssp {
; Don't be fragile about which loads or manipulations of the base register
; are used---just check that there isn't an ldp before the add
; CHECK-LABEL: pairUpBarelyOutSext:
; CHECK: // %bb.0:
; CHECK-NEXT: sub x8, x0, #260
; CHECK-NEXT: ldursw x9, [x0, #-256]
; CHECK-NEXT: ldrsw x8, [x8]
; CHECK-NEXT: add x0, x9, x8
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i32, i32* %a, i64 -64
%tmp1 = load i32, i32* %p1, align 2
%p2 = getelementptr inbounds i32, i32* %a, i64 -65
%tmp2 = load i32, i32* %p2, align 2
%sexttmp1 = sext i32 %tmp1 to i64
%sexttmp2 = sext i32 %tmp2 to i64
%tmp3 = add i64 %sexttmp1, %sexttmp2
ret i64 %tmp3
}
define i64 @pairUpNotAligned(i64* %a) nounwind ssp {
; CHECK-LABEL: pairUpNotAligned:
; CHECK: // %bb.0:
; CHECK-NEXT: ldur x8, [x0, #-143]
; CHECK-NEXT: ldur x9, [x0, #-135]
; CHECK-NEXT: add x0, x8, x9
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i64, i64* %a, i64 -18
%bp1 = bitcast i64* %p1 to i8*
%bp1p1 = getelementptr inbounds i8, i8* %bp1, i64 1
%dp1 = bitcast i8* %bp1p1 to i64*
%tmp1 = load i64, i64* %dp1, align 1
%p2 = getelementptr inbounds i64, i64* %a, i64 -17
%bp2 = bitcast i64* %p2 to i8*
%bp2p1 = getelementptr inbounds i8, i8* %bp2, i64 1
%dp2 = bitcast i8* %bp2p1 to i64*
%tmp2 = load i64, i64* %dp2, align 1
%tmp3 = add i64 %tmp1, %tmp2
ret i64 %tmp3
}
define i64 @pairUpNotAlignedSext(i32* %a) nounwind ssp {
; CHECK-LABEL: pairUpNotAlignedSext:
; CHECK: // %bb.0:
; CHECK-NEXT: ldursw x8, [x0, #-71]
; CHECK-NEXT: ldursw x9, [x0, #-67]
; CHECK-NEXT: add x0, x8, x9
; CHECK-NEXT: ret
%p1 = getelementptr inbounds i32, i32* %a, i64 -18
%bp1 = bitcast i32* %p1 to i8*
%bp1p1 = getelementptr inbounds i8, i8* %bp1, i64 1
%dp1 = bitcast i8* %bp1p1 to i32*
%tmp1 = load i32, i32* %dp1, align 1
%p2 = getelementptr inbounds i32, i32* %a, i64 -17
%bp2 = bitcast i32* %p2 to i8*
%bp2p1 = getelementptr inbounds i8, i8* %bp2, i64 1
%dp2 = bitcast i8* %bp2p1 to i32*
%tmp2 = load i32, i32* %dp2, align 1
%sexttmp1 = sext i32 %tmp1 to i64
%sexttmp2 = sext i32 %tmp2 to i64
%tmp3 = add i64 %sexttmp1, %sexttmp2
ret i64 %tmp3
}
declare void @use-ptr(i32*)
define i64 @ldp_sext_int_pre(i32* %p) nounwind {
; CHECK-LABEL: ldp_sext_int_pre:
; CHECK: // %bb.0:
; CHECK-NEXT: stp x30, x19, [sp, #-16]! // 16-byte Folded Spill
; CHECK-NEXT: mov x19, x0
; CHECK-NEXT: add x0, x0, #8
; CHECK-NEXT: bl "use-ptr"
; CHECK-NEXT: ldpsw x8, x9, [x19, #8]
; CHECK-NEXT: add x0, x9, x8
; CHECK-NEXT: ldp x30, x19, [sp], #16 // 16-byte Folded Reload
; CHECK-NEXT: ret
%ptr = getelementptr inbounds i32, i32* %p, i64 2
call void @use-ptr(i32* %ptr)
%add.ptr = getelementptr inbounds i32, i32* %ptr, i64 0
%tmp = load i32, i32* %add.ptr, align 4
%add.ptr1 = getelementptr inbounds i32, i32* %ptr, i64 1
%tmp1 = load i32, i32* %add.ptr1, align 4
%sexttmp = sext i32 %tmp to i64
%sexttmp1 = sext i32 %tmp1 to i64
%add = add nsw i64 %sexttmp1, %sexttmp
ret i64 %add
}
define i64 @ldp_sext_int_post(i32* %p) nounwind {
; CHECK-LABEL: ldp_sext_int_post:
; CHECK: // %bb.0:
; CHECK-NEXT: str x30, [sp, #-32]! // 8-byte Folded Spill
; CHECK-NEXT: add x8, x0, #8
; CHECK-NEXT: stp x20, x19, [sp, #16] // 16-byte Folded Spill
; CHECK-NEXT: ldpsw x19, x20, [x0]
; CHECK-NEXT: mov x0, x8
; CHECK-NEXT: bl "use-ptr"
; CHECK-NEXT: add x0, x20, x19
; CHECK-NEXT: ldp x20, x19, [sp, #16] // 16-byte Folded Reload
; CHECK-NEXT: ldr x30, [sp], #32 // 8-byte Folded Reload
; CHECK-NEXT: ret
%tmp = load i32, i32* %p, align 4
%add.ptr = getelementptr inbounds i32, i32* %p, i64 1
%tmp1 = load i32, i32* %add.ptr, align 4
%sexttmp = sext i32 %tmp to i64
%sexttmp1 = sext i32 %tmp1 to i64
%ptr = getelementptr inbounds i32, i32* %add.ptr, i64 1
call void @use-ptr(i32* %ptr)
%add = add nsw i64 %sexttmp1, %sexttmp
ret i64 %add
}
|