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 stptr.w is not emitted for small offsets.
6 define void @stptr_w_too_small_offset(ptr %p, i32 signext %val) nounwind {
7 ; LA32-LABEL: stptr_w_too_small_offset:
9 ; LA32-NEXT: st.w $a1, $a0, 2044
12 ; LA64-LABEL: stptr_w_too_small_offset:
14 ; LA64-NEXT: st.w $a1, $a0, 2044
16 %addr = getelementptr inbounds i32, ptr %p, i64 511
17 store i32 %val, ptr %addr, align 4
21 ;; Check that stptr.w is emitted for applicable offsets.
22 define void @stptr_w(ptr %p, i32 signext %val) nounwind {
23 ; LA32-LABEL: stptr_w:
25 ; LA32-NEXT: addi.w $a0, $a0, 2047
26 ; LA32-NEXT: addi.w $a0, $a0, 1
27 ; LA32-NEXT: st.w $a1, $a0, 0
30 ; LA64-LABEL: stptr_w:
32 ; LA64-NEXT: stptr.w $a1, $a0, 2048
34 %addr = getelementptr inbounds i32, ptr %p, i64 512
35 store i32 %val, ptr %addr, align 4
39 ;; Check that stptr.w is not emitted for out-of-range offsets.
40 define void @stptr_w_too_big_offset(ptr %p, i32 signext %val) nounwind {
41 ; LA32-LABEL: stptr_w_too_big_offset:
43 ; LA32-NEXT: lu12i.w $a2, 8
44 ; LA32-NEXT: add.w $a0, $a0, $a2
45 ; LA32-NEXT: st.w $a1, $a0, 0
48 ; LA64-LABEL: stptr_w_too_big_offset:
50 ; LA64-NEXT: lu12i.w $a2, 8
51 ; LA64-NEXT: stx.w $a1, $a0, $a2
53 %addr = getelementptr inbounds i32, ptr %p, i64 8192
54 store i32 %val, ptr %addr, align 4
58 ;; Check that stptr.d is not emitted for small offsets.
59 define void @stptr_d_too_small_offset(ptr %p, i64 %val) nounwind {
60 ; LA32-LABEL: stptr_d_too_small_offset:
62 ; LA32-NEXT: st.w $a2, $a0, 2044
63 ; LA32-NEXT: st.w $a1, $a0, 2040
66 ; LA64-LABEL: stptr_d_too_small_offset:
68 ; LA64-NEXT: st.d $a1, $a0, 2040
70 %addr = getelementptr inbounds i64, ptr %p, i64 255
71 store i64 %val, ptr %addr, align 8
75 ;; Check that stptr.d is emitted for applicable offsets.
76 define void @stptr_d(ptr %p, i64 %val) nounwind {
77 ; LA32-LABEL: stptr_d:
79 ; LA32-NEXT: addi.w $a0, $a0, 2047
80 ; LA32-NEXT: addi.w $a0, $a0, 1
81 ; LA32-NEXT: st.w $a2, $a0, 4
82 ; LA32-NEXT: st.w $a1, $a0, 0
85 ; LA64-LABEL: stptr_d:
87 ; LA64-NEXT: stptr.d $a1, $a0, 2048
89 %addr = getelementptr inbounds i64, ptr %p, i64 256
90 store i64 %val, ptr %addr, align 8
94 ;; Check that stptr.d is not emitted for out-of-range offsets.
95 define void @stptr_d_too_big_offset(ptr %p, i64 %val) nounwind {
96 ; LA32-LABEL: stptr_d_too_big_offset:
98 ; LA32-NEXT: lu12i.w $a3, 8
99 ; LA32-NEXT: add.w $a0, $a0, $a3
100 ; LA32-NEXT: st.w $a2, $a0, 4
101 ; LA32-NEXT: st.w $a1, $a0, 0
104 ; LA64-LABEL: stptr_d_too_big_offset:
106 ; LA64-NEXT: lu12i.w $a2, 8
107 ; LA64-NEXT: stx.d $a1, $a0, $a2
109 %addr = getelementptr inbounds i64, ptr %p, i64 4096
110 store i64 %val, ptr %addr, align 8