1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 -mattr=+d < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck %s --check-prefix=LA64
5 ;; Check that ldptr.w is not emitted for small offsets.
6 define signext i32 @ldptr_w_too_small_offset(ptr %p) nounwind {
7 ; LA32-LABEL: ldptr_w_too_small_offset:
8 ; LA32: # %bb.0: # %entry
9 ; LA32-NEXT: ld.w $a0, $a0, 2044
12 ; LA64-LABEL: ldptr_w_too_small_offset:
13 ; LA64: # %bb.0: # %entry
14 ; LA64-NEXT: ld.w $a0, $a0, 2044
17 %addr = getelementptr inbounds i32, ptr %p, i64 511
18 %val = load i32, ptr %addr, align 4
22 ;; Check that ldptr.w is emitted for applicable offsets.
23 define signext i32 @ldptr_w(ptr %p) nounwind {
24 ; LA32-LABEL: ldptr_w:
25 ; LA32: # %bb.0: # %entry
26 ; LA32-NEXT: addi.w $a0, $a0, 2047
27 ; LA32-NEXT: addi.w $a0, $a0, 1
28 ; LA32-NEXT: ld.w $a0, $a0, 0
31 ; LA64-LABEL: ldptr_w:
32 ; LA64: # %bb.0: # %entry
33 ; LA64-NEXT: ldptr.w $a0, $a0, 2048
36 %addr = getelementptr inbounds i32, ptr %p, i64 512
37 %val = load i32, ptr %addr, align 4
41 ;; Check that ldptr.w is not emitted for out-of-range offsets.
42 define signext i32 @ldptr_w_too_big_offset(ptr %p) nounwind {
43 ; LA32-LABEL: ldptr_w_too_big_offset:
44 ; LA32: # %bb.0: # %entry
45 ; LA32-NEXT: lu12i.w $a1, 8
46 ; LA32-NEXT: add.w $a0, $a0, $a1
47 ; LA32-NEXT: ld.w $a0, $a0, 0
50 ; LA64-LABEL: ldptr_w_too_big_offset:
51 ; LA64: # %bb.0: # %entry
52 ; LA64-NEXT: lu12i.w $a1, 8
53 ; LA64-NEXT: ldx.w $a0, $a0, $a1
56 %addr = getelementptr inbounds i32, ptr %p, i64 8192
57 %val = load i32, ptr %addr, align 4
61 ;; Check that ldptr.d is not emitted for small offsets.
62 define i64 @ldptr_d_too_small_offset(ptr %p) nounwind {
63 ; LA32-LABEL: ldptr_d_too_small_offset:
64 ; LA32: # %bb.0: # %entry
65 ; LA32-NEXT: ld.w $a2, $a0, 2040
66 ; LA32-NEXT: ld.w $a1, $a0, 2044
67 ; LA32-NEXT: move $a0, $a2
70 ; LA64-LABEL: ldptr_d_too_small_offset:
71 ; LA64: # %bb.0: # %entry
72 ; LA64-NEXT: ld.d $a0, $a0, 2040
75 %addr = getelementptr inbounds i64, ptr %p, i64 255
76 %val = load i64, ptr %addr, align 8
80 ;; Check that ldptr.d is emitted for applicable offsets.
81 define i64 @ldptr_d(ptr %p) nounwind {
82 ; LA32-LABEL: ldptr_d:
83 ; LA32: # %bb.0: # %entry
84 ; LA32-NEXT: addi.w $a0, $a0, 2047
85 ; LA32-NEXT: addi.w $a1, $a0, 1
86 ; LA32-NEXT: ld.w $a0, $a1, 0
87 ; LA32-NEXT: ld.w $a1, $a1, 4
90 ; LA64-LABEL: ldptr_d:
91 ; LA64: # %bb.0: # %entry
92 ; LA64-NEXT: ldptr.d $a0, $a0, 2048
95 %addr = getelementptr inbounds i64, ptr %p, i64 256
96 %val = load i64, ptr %addr, align 8
100 ;; Check that ldptr.d is not emitted for out-of-range offsets.
101 define i64 @ldptr_d_too_big_offset(ptr %p) nounwind {
102 ; LA32-LABEL: ldptr_d_too_big_offset:
103 ; LA32: # %bb.0: # %entry
104 ; LA32-NEXT: lu12i.w $a1, 8
105 ; LA32-NEXT: add.w $a1, $a0, $a1
106 ; LA32-NEXT: ld.w $a0, $a1, 0
107 ; LA32-NEXT: ld.w $a1, $a1, 4
110 ; LA64-LABEL: ldptr_d_too_big_offset:
111 ; LA64: # %bb.0: # %entry
112 ; LA64-NEXT: lu12i.w $a1, 8
113 ; LA64-NEXT: ldx.d $a0, $a0, $a1
116 %addr = getelementptr inbounds i64, ptr %p, i64 4096
117 %val = load i64, ptr %addr, align 8