1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 --verify-machineinstrs < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 --verify-machineinstrs < %s | FileCheck %s --check-prefix=LA64
5 define i32 @ZC_offset_neg_32769(ptr %p) nounwind {
6 ; LA32-LABEL: ZC_offset_neg_32769:
8 ; LA32-NEXT: lu12i.w $a1, -9
9 ; LA32-NEXT: ori $a1, $a1, 4095
10 ; LA32-NEXT: add.w $a0, $a0, $a1
12 ; LA32-NEXT: ll.w $a0, $a0, 0
16 ; LA64-LABEL: ZC_offset_neg_32769:
18 ; LA64-NEXT: lu12i.w $a1, -9
19 ; LA64-NEXT: ori $a1, $a1, 4095
20 ; LA64-NEXT: add.d $a0, $a0, $a1
22 ; LA64-NEXT: ll.w $a0, $a0, 0
25 %1 = getelementptr inbounds i8, ptr %p, i32 -32769
26 %2 = call i32 asm "ll.w $0, $1", "=r,*^ZC"(ptr elementtype(i32) %1)
30 define i32 @ZC_offset_neg_32768(ptr %p) nounwind {
31 ; LA32-LABEL: ZC_offset_neg_32768:
34 ; LA32-NEXT: ll.w $a0, $a0, -32768
38 ; LA64-LABEL: ZC_offset_neg_32768:
41 ; LA64-NEXT: ll.w $a0, $a0, -32768
44 %1 = getelementptr inbounds i8, ptr %p, i32 -32768
45 %2 = call i32 asm "ll.w $0, $1", "=r,*^ZC"(ptr elementtype(i32) %1)
49 define i32 @ZC_offset_neg_4(ptr %p) nounwind {
50 ; LA32-LABEL: ZC_offset_neg_4:
53 ; LA32-NEXT: ll.w $a0, $a0, -4
57 ; LA64-LABEL: ZC_offset_neg_4:
60 ; LA64-NEXT: ll.w $a0, $a0, -4
63 %1 = getelementptr inbounds i8, ptr %p, i32 -4
64 %2 = call i32 asm "ll.w $0, $1", "=r,*^ZC"(ptr elementtype(i32) %1)
68 define i32 @ZC_offset_neg_1(ptr %p) nounwind {
69 ; LA32-LABEL: ZC_offset_neg_1:
71 ; LA32-NEXT: addi.w $a0, $a0, -1
73 ; LA32-NEXT: ll.w $a0, $a0, 0
77 ; LA64-LABEL: ZC_offset_neg_1:
79 ; LA64-NEXT: addi.d $a0, $a0, -1
81 ; LA64-NEXT: ll.w $a0, $a0, 0
84 %1 = getelementptr inbounds i8, ptr %p, i32 -1
85 %2 = call i32 asm "ll.w $0, $1", "=r,*^ZC"(ptr elementtype(i32) %1)
89 define i32 @ZC_offset_0(ptr %p) nounwind {
90 ; LA32-LABEL: ZC_offset_0:
93 ; LA32-NEXT: ll.w $a0, $a0, 0
97 ; LA64-LABEL: ZC_offset_0:
100 ; LA64-NEXT: ll.w $a0, $a0, 0
103 %1 = call i32 asm "ll.w $0, $1", "=r,*^ZC"(ptr elementtype(i32) %p)
107 define i32 @ZC_offset_1(ptr %p) nounwind {
108 ; LA32-LABEL: ZC_offset_1:
110 ; LA32-NEXT: addi.w $a0, $a0, 1
112 ; LA32-NEXT: ll.w $a0, $a0, 0
116 ; LA64-LABEL: ZC_offset_1:
118 ; LA64-NEXT: addi.d $a0, $a0, 1
120 ; LA64-NEXT: ll.w $a0, $a0, 0
123 %1 = getelementptr inbounds i8, ptr %p, i32 1
124 %2 = call i32 asm "ll.w $0, $1", "=r,*^ZC"(ptr elementtype(i32) %1)
128 define i32 @ZC_offset_32764(ptr %p) nounwind {
129 ; LA32-LABEL: ZC_offset_32764:
132 ; LA32-NEXT: ll.w $a0, $a0, 32764
136 ; LA64-LABEL: ZC_offset_32764:
139 ; LA64-NEXT: ll.w $a0, $a0, 32764
142 %1 = getelementptr inbounds i8, ptr %p, i32 32764
143 %2 = call i32 asm "ll.w $0, $1", "=r,*^ZC"(ptr elementtype(i32) %1)
147 define i32 @ZC_offset_32767(ptr %p) nounwind {
148 ; LA32-LABEL: ZC_offset_32767:
150 ; LA32-NEXT: lu12i.w $a1, 7
151 ; LA32-NEXT: ori $a1, $a1, 4095
152 ; LA32-NEXT: add.w $a0, $a0, $a1
154 ; LA32-NEXT: ll.w $a0, $a0, 0
158 ; LA64-LABEL: ZC_offset_32767:
160 ; LA64-NEXT: lu12i.w $a1, 7
161 ; LA64-NEXT: ori $a1, $a1, 4095
162 ; LA64-NEXT: add.d $a0, $a0, $a1
164 ; LA64-NEXT: ll.w $a0, $a0, 0
167 %1 = getelementptr inbounds i8, ptr %p, i32 32767
168 %2 = call i32 asm "ll.w $0, $1", "=r,*^ZC"(ptr elementtype(i32) %1)