Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / test / CodeGen / LoongArch / psabi-restricted-scheduling.ll
blob6a15d3a9cda307388d0ab33d65e8f0d1f909f8aa
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc --mtriple=loongarch64 -mattr=+d --code-model=medium --relocation-model=pic --post-RA-scheduler=0 < %s \
3 ; RUN:     | FileCheck %s --check-prefix=MEDIUM_NO_SCH
4 ; RUN: llc --mtriple=loongarch64 -mattr=+d --code-model=medium --relocation-model=pic --post-RA-scheduler=1 < %s \
5 ; RUN:     | FileCheck %s --check-prefix=MEDIUM_SCH
6 ; RUN: llc --mtriple=loongarch64 -mattr=+d --code-model=large --relocation-model=pic --post-RA-scheduler=0 < %s \
7 ; RUN:     | FileCheck %s --check-prefix=LARGE_NO_SCH
8 ; RUN: llc --mtriple=loongarch64 -mattr=+d --code-model=large --relocation-model=pic --post-RA-scheduler=1 < %s \
9 ; RUN:     | FileCheck %s --check-prefix=LARGE_SCH
11 @g = dso_local global i64 zeroinitializer, align 4
12 @G = global i64 zeroinitializer, align 4
13 @gd = external thread_local global i64
14 @ld = external thread_local(localdynamic) global i64
15 @ie = external thread_local(initialexec) global i64
17 declare ptr @bar(i64)
19 define void @foo() nounwind {
20 ; MEDIUM_NO_SCH-LABEL: foo:
21 ; MEDIUM_NO_SCH:       # %bb.0:
22 ; MEDIUM_NO_SCH-NEXT:    addi.d $sp, $sp, -16
23 ; MEDIUM_NO_SCH-NEXT:    st.d $ra, $sp, 8 # 8-byte Folded Spill
24 ; MEDIUM_NO_SCH-NEXT:    pcalau12i $a0, %got_pc_hi20(G)
25 ; MEDIUM_NO_SCH-NEXT:    ld.d $a0, $a0, %got_pc_lo12(G)
26 ; MEDIUM_NO_SCH-NEXT:    ld.d $zero, $a0, 0
27 ; MEDIUM_NO_SCH-NEXT:    pcalau12i $a0, %pc_hi20(.Lg$local)
28 ; MEDIUM_NO_SCH-NEXT:    addi.d $a0, $a0, %pc_lo12(.Lg$local)
29 ; MEDIUM_NO_SCH-NEXT:    ld.d $zero, $a0, 0
30 ; MEDIUM_NO_SCH-NEXT:    ori $a0, $zero, 1
31 ; MEDIUM_NO_SCH-NEXT:    pcaddu18i $ra, %call36(bar)
32 ; MEDIUM_NO_SCH-NEXT:    jirl $ra, $ra, 0
33 ; MEDIUM_NO_SCH-NEXT:    pcalau12i $a0, %gd_pc_hi20(gd)
34 ; MEDIUM_NO_SCH-NEXT:    addi.d $a0, $a0, %got_pc_lo12(gd)
35 ; MEDIUM_NO_SCH-NEXT:    pcaddu18i $ra, %call36(__tls_get_addr)
36 ; MEDIUM_NO_SCH-NEXT:    jirl $ra, $ra, 0
37 ; MEDIUM_NO_SCH-NEXT:    ld.d $zero, $a0, 0
38 ; MEDIUM_NO_SCH-NEXT:    pcalau12i $a0, %ld_pc_hi20(ld)
39 ; MEDIUM_NO_SCH-NEXT:    addi.d $a0, $a0, %got_pc_lo12(ld)
40 ; MEDIUM_NO_SCH-NEXT:    pcaddu18i $ra, %call36(__tls_get_addr)
41 ; MEDIUM_NO_SCH-NEXT:    jirl $ra, $ra, 0
42 ; MEDIUM_NO_SCH-NEXT:    pcalau12i $a1, %ie_pc_hi20(ie)
43 ; MEDIUM_NO_SCH-NEXT:    ld.d $a1, $a1, %ie_pc_lo12(ie)
44 ; MEDIUM_NO_SCH-NEXT:    ld.d $zero, $a0, 0
45 ; MEDIUM_NO_SCH-NEXT:    ldx.d $zero, $a1, $tp
46 ; MEDIUM_NO_SCH-NEXT:    ld.d $ra, $sp, 8 # 8-byte Folded Reload
47 ; MEDIUM_NO_SCH-NEXT:    addi.d $sp, $sp, 16
48 ; MEDIUM_NO_SCH-NEXT:    ret
50 ; MEDIUM_SCH-LABEL: foo:
51 ; MEDIUM_SCH:       # %bb.0:
52 ; MEDIUM_SCH-NEXT:    addi.d $sp, $sp, -16
53 ; MEDIUM_SCH-NEXT:    st.d $ra, $sp, 8 # 8-byte Folded Spill
54 ; MEDIUM_SCH-NEXT:    pcalau12i $a0, %got_pc_hi20(G)
55 ; MEDIUM_SCH-NEXT:    ld.d $a0, $a0, %got_pc_lo12(G)
56 ; MEDIUM_SCH-NEXT:    ld.d $zero, $a0, 0
57 ; MEDIUM_SCH-NEXT:    pcalau12i $a0, %pc_hi20(.Lg$local)
58 ; MEDIUM_SCH-NEXT:    addi.d $a0, $a0, %pc_lo12(.Lg$local)
59 ; MEDIUM_SCH-NEXT:    ld.d $zero, $a0, 0
60 ; MEDIUM_SCH-NEXT:    ori $a0, $zero, 1
61 ; MEDIUM_SCH-NEXT:    pcaddu18i $ra, %call36(bar)
62 ; MEDIUM_SCH-NEXT:    jirl $ra, $ra, 0
63 ; MEDIUM_SCH-NEXT:    pcalau12i $a0, %gd_pc_hi20(gd)
64 ; MEDIUM_SCH-NEXT:    addi.d $a0, $a0, %got_pc_lo12(gd)
65 ; MEDIUM_SCH-NEXT:    pcaddu18i $ra, %call36(__tls_get_addr)
66 ; MEDIUM_SCH-NEXT:    jirl $ra, $ra, 0
67 ; MEDIUM_SCH-NEXT:    ld.d $zero, $a0, 0
68 ; MEDIUM_SCH-NEXT:    pcalau12i $a0, %ld_pc_hi20(ld)
69 ; MEDIUM_SCH-NEXT:    addi.d $a0, $a0, %got_pc_lo12(ld)
70 ; MEDIUM_SCH-NEXT:    pcaddu18i $ra, %call36(__tls_get_addr)
71 ; MEDIUM_SCH-NEXT:    jirl $ra, $ra, 0
72 ; MEDIUM_SCH-NEXT:    pcalau12i $a1, %ie_pc_hi20(ie)
73 ; MEDIUM_SCH-NEXT:    ld.d $zero, $a0, 0
74 ; MEDIUM_SCH-NEXT:    ld.d $a1, $a1, %ie_pc_lo12(ie)
75 ; MEDIUM_SCH-NEXT:    ldx.d $zero, $a1, $tp
76 ; MEDIUM_SCH-NEXT:    ld.d $ra, $sp, 8 # 8-byte Folded Reload
77 ; MEDIUM_SCH-NEXT:    addi.d $sp, $sp, 16
78 ; MEDIUM_SCH-NEXT:    ret
80 ; LARGE_NO_SCH-LABEL: foo:
81 ; LARGE_NO_SCH:       # %bb.0:
82 ; LARGE_NO_SCH-NEXT:    addi.d $sp, $sp, -16
83 ; LARGE_NO_SCH-NEXT:    st.d $ra, $sp, 8 # 8-byte Folded Spill
84 ; LARGE_NO_SCH-NEXT:    pcalau12i $a0, %got_pc_hi20(G)
85 ; LARGE_NO_SCH-NEXT:    addi.d $t8, $zero, %got_pc_lo12(G)
86 ; LARGE_NO_SCH-NEXT:    lu32i.d $t8, %got64_pc_lo20(G)
87 ; LARGE_NO_SCH-NEXT:    lu52i.d $t8, $t8, %got64_pc_hi12(G)
88 ; LARGE_NO_SCH-NEXT:    ldx.d $a0, $t8, $a0
89 ; LARGE_NO_SCH-NEXT:    ld.d $zero, $a0, 0
90 ; LARGE_NO_SCH-NEXT:    pcalau12i $a0, %pc_hi20(.Lg$local)
91 ; LARGE_NO_SCH-NEXT:    addi.d $t8, $zero, %pc_lo12(.Lg$local)
92 ; LARGE_NO_SCH-NEXT:    lu32i.d $t8, %pc64_lo20(.Lg$local)
93 ; LARGE_NO_SCH-NEXT:    lu52i.d $t8, $t8, %pc64_hi12(.Lg$local)
94 ; LARGE_NO_SCH-NEXT:    add.d $a0, $t8, $a0
95 ; LARGE_NO_SCH-NEXT:    ld.d $zero, $a0, 0
96 ; LARGE_NO_SCH-NEXT:    ori $a0, $zero, 1
97 ; LARGE_NO_SCH-NEXT:    pcalau12i $ra, %got_pc_hi20(bar)
98 ; LARGE_NO_SCH-NEXT:    addi.d $t8, $zero, %got_pc_lo12(bar)
99 ; LARGE_NO_SCH-NEXT:    lu32i.d $t8, %got64_pc_lo20(bar)
100 ; LARGE_NO_SCH-NEXT:    lu52i.d $t8, $t8, %got64_pc_hi12(bar)
101 ; LARGE_NO_SCH-NEXT:    ldx.d $ra, $t8, $ra
102 ; LARGE_NO_SCH-NEXT:    jirl $ra, $ra, 0
103 ; LARGE_NO_SCH-NEXT:    pcalau12i $a0, %gd_pc_hi20(gd)
104 ; LARGE_NO_SCH-NEXT:    addi.d $t8, $zero, %got_pc_lo12(gd)
105 ; LARGE_NO_SCH-NEXT:    lu32i.d $t8, %got64_pc_lo20(gd)
106 ; LARGE_NO_SCH-NEXT:    lu52i.d $t8, $t8, %got64_pc_hi12(gd)
107 ; LARGE_NO_SCH-NEXT:    add.d $a0, $t8, $a0
108 ; LARGE_NO_SCH-NEXT:    pcalau12i $ra, %pc_hi20(__tls_get_addr)
109 ; LARGE_NO_SCH-NEXT:    addi.d $t8, $zero, %pc_lo12(__tls_get_addr)
110 ; LARGE_NO_SCH-NEXT:    lu32i.d $t8, %pc64_lo20(__tls_get_addr)
111 ; LARGE_NO_SCH-NEXT:    lu52i.d $t8, $t8, %pc64_hi12(__tls_get_addr)
112 ; LARGE_NO_SCH-NEXT:    add.d $ra, $t8, $ra
113 ; LARGE_NO_SCH-NEXT:    jirl $ra, $ra, 0
114 ; LARGE_NO_SCH-NEXT:    ld.d $zero, $a0, 0
115 ; LARGE_NO_SCH-NEXT:    pcalau12i $a0, %ld_pc_hi20(ld)
116 ; LARGE_NO_SCH-NEXT:    addi.d $t8, $zero, %got_pc_lo12(ld)
117 ; LARGE_NO_SCH-NEXT:    lu32i.d $t8, %got64_pc_lo20(ld)
118 ; LARGE_NO_SCH-NEXT:    lu52i.d $t8, $t8, %got64_pc_hi12(ld)
119 ; LARGE_NO_SCH-NEXT:    add.d $a0, $t8, $a0
120 ; LARGE_NO_SCH-NEXT:    pcalau12i $ra, %pc_hi20(__tls_get_addr)
121 ; LARGE_NO_SCH-NEXT:    addi.d $t8, $zero, %pc_lo12(__tls_get_addr)
122 ; LARGE_NO_SCH-NEXT:    lu32i.d $t8, %pc64_lo20(__tls_get_addr)
123 ; LARGE_NO_SCH-NEXT:    lu52i.d $t8, $t8, %pc64_hi12(__tls_get_addr)
124 ; LARGE_NO_SCH-NEXT:    add.d $ra, $t8, $ra
125 ; LARGE_NO_SCH-NEXT:    jirl $ra, $ra, 0
126 ; LARGE_NO_SCH-NEXT:    pcalau12i $a1, %ie_pc_hi20(ie)
127 ; LARGE_NO_SCH-NEXT:    addi.d $t8, $zero, %ie_pc_lo12(ie)
128 ; LARGE_NO_SCH-NEXT:    lu32i.d $t8, %ie64_pc_lo20(ie)
129 ; LARGE_NO_SCH-NEXT:    lu52i.d $t8, $t8, %ie64_pc_hi12(ie)
130 ; LARGE_NO_SCH-NEXT:    ldx.d $a1, $t8, $a1
131 ; LARGE_NO_SCH-NEXT:    ld.d $zero, $a0, 0
132 ; LARGE_NO_SCH-NEXT:    ldx.d $zero, $a1, $tp
133 ; LARGE_NO_SCH-NEXT:    ld.d $ra, $sp, 8 # 8-byte Folded Reload
134 ; LARGE_NO_SCH-NEXT:    addi.d $sp, $sp, 16
135 ; LARGE_NO_SCH-NEXT:    ret
137 ; LARGE_SCH-LABEL: foo:
138 ; LARGE_SCH:       # %bb.0:
139 ; LARGE_SCH-NEXT:    addi.d $sp, $sp, -16
140 ; LARGE_SCH-NEXT:    st.d $ra, $sp, 8 # 8-byte Folded Spill
141 ; LARGE_SCH-NEXT:    pcalau12i $a0, %got_pc_hi20(G)
142 ; LARGE_SCH-NEXT:    addi.d $t8, $zero, %got_pc_lo12(G)
143 ; LARGE_SCH-NEXT:    lu32i.d $t8, %got64_pc_lo20(G)
144 ; LARGE_SCH-NEXT:    lu52i.d $t8, $t8, %got64_pc_hi12(G)
145 ; LARGE_SCH-NEXT:    ldx.d $a0, $t8, $a0
146 ; LARGE_SCH-NEXT:    ld.d $zero, $a0, 0
147 ; LARGE_SCH-NEXT:    pcalau12i $a0, %pc_hi20(.Lg$local)
148 ; LARGE_SCH-NEXT:    addi.d $t8, $zero, %pc_lo12(.Lg$local)
149 ; LARGE_SCH-NEXT:    lu32i.d $t8, %pc64_lo20(.Lg$local)
150 ; LARGE_SCH-NEXT:    lu52i.d $t8, $t8, %pc64_hi12(.Lg$local)
151 ; LARGE_SCH-NEXT:    add.d $a0, $t8, $a0
152 ; LARGE_SCH-NEXT:    ld.d $zero, $a0, 0
153 ; LARGE_SCH-NEXT:    ori $a0, $zero, 1
154 ; LARGE_SCH-NEXT:    pcalau12i $ra, %got_pc_hi20(bar)
155 ; LARGE_SCH-NEXT:    addi.d $t8, $zero, %got_pc_lo12(bar)
156 ; LARGE_SCH-NEXT:    lu32i.d $t8, %got64_pc_lo20(bar)
157 ; LARGE_SCH-NEXT:    lu52i.d $t8, $t8, %got64_pc_hi12(bar)
158 ; LARGE_SCH-NEXT:    ldx.d $ra, $t8, $ra
159 ; LARGE_SCH-NEXT:    jirl $ra, $ra, 0
160 ; LARGE_SCH-NEXT:    pcalau12i $a0, %gd_pc_hi20(gd)
161 ; LARGE_SCH-NEXT:    addi.d $t8, $zero, %got_pc_lo12(gd)
162 ; LARGE_SCH-NEXT:    lu32i.d $t8, %got64_pc_lo20(gd)
163 ; LARGE_SCH-NEXT:    lu52i.d $t8, $t8, %got64_pc_hi12(gd)
164 ; LARGE_SCH-NEXT:    add.d $a0, $t8, $a0
165 ; LARGE_SCH-NEXT:    pcalau12i $ra, %pc_hi20(__tls_get_addr)
166 ; LARGE_SCH-NEXT:    addi.d $t8, $zero, %pc_lo12(__tls_get_addr)
167 ; LARGE_SCH-NEXT:    lu32i.d $t8, %pc64_lo20(__tls_get_addr)
168 ; LARGE_SCH-NEXT:    lu52i.d $t8, $t8, %pc64_hi12(__tls_get_addr)
169 ; LARGE_SCH-NEXT:    add.d $ra, $t8, $ra
170 ; LARGE_SCH-NEXT:    jirl $ra, $ra, 0
171 ; LARGE_SCH-NEXT:    ld.d $zero, $a0, 0
172 ; LARGE_SCH-NEXT:    pcalau12i $a0, %ld_pc_hi20(ld)
173 ; LARGE_SCH-NEXT:    addi.d $t8, $zero, %got_pc_lo12(ld)
174 ; LARGE_SCH-NEXT:    lu32i.d $t8, %got64_pc_lo20(ld)
175 ; LARGE_SCH-NEXT:    lu52i.d $t8, $t8, %got64_pc_hi12(ld)
176 ; LARGE_SCH-NEXT:    add.d $a0, $t8, $a0
177 ; LARGE_SCH-NEXT:    pcalau12i $ra, %pc_hi20(__tls_get_addr)
178 ; LARGE_SCH-NEXT:    addi.d $t8, $zero, %pc_lo12(__tls_get_addr)
179 ; LARGE_SCH-NEXT:    lu32i.d $t8, %pc64_lo20(__tls_get_addr)
180 ; LARGE_SCH-NEXT:    lu52i.d $t8, $t8, %pc64_hi12(__tls_get_addr)
181 ; LARGE_SCH-NEXT:    add.d $ra, $t8, $ra
182 ; LARGE_SCH-NEXT:    jirl $ra, $ra, 0
183 ; LARGE_SCH-NEXT:    pcalau12i $a1, %ie_pc_hi20(ie)
184 ; LARGE_SCH-NEXT:    addi.d $t8, $zero, %ie_pc_lo12(ie)
185 ; LARGE_SCH-NEXT:    lu32i.d $t8, %ie64_pc_lo20(ie)
186 ; LARGE_SCH-NEXT:    lu52i.d $t8, $t8, %ie64_pc_hi12(ie)
187 ; LARGE_SCH-NEXT:    ldx.d $a1, $t8, $a1
188 ; LARGE_SCH-NEXT:    ld.d $zero, $a0, 0
189 ; LARGE_SCH-NEXT:    ldx.d $zero, $a1, $tp
190 ; LARGE_SCH-NEXT:    ld.d $ra, $sp, 8 # 8-byte Folded Reload
191 ; LARGE_SCH-NEXT:    addi.d $sp, $sp, 16
192 ; LARGE_SCH-NEXT:    ret
193   %V = load volatile i64, ptr @G
194   %v = load volatile i64, ptr @g
195   call void @bar(i64 1)
196   %v_gd = load volatile i64, ptr @gd
197   %v_ld = load volatile i64, ptr @ld
198   %v_ie = load volatile i64, ptr @ie
199   ret void