llvm.org GIT mirror llvm / c86e4bc
[GlobalISel] Don't select trivially dead instructions. Folding instructions when selecting can cause them to become dead. Don't select these dead instructions (if they don't have other side effects, and don't define physical registers). Preserve existing tests by adding COPYs. In some tests, the G_CONSTANT vregs never get constrained to a class: the only use of the vreg was folded into another instruction, so the G_CONSTANT, now dead, never gets selected. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298224 91177308-0d34-0410-b5e6-96231b3b80d8 Ahmed Bougacha 2 years ago
15 changed file(s) with 172 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
4545 void InstructionSelect::getAnalysisUsage(AnalysisUsage &AU) const {
4646 AU.addRequired();
4747 MachineFunctionPass::getAnalysisUsage(AU);
48 }
49
50 /// Check whether an instruction \p MI is dead: it only defines dead virtual
51 /// registers, and doesn't have other side effects.
52 static bool isTriviallyDead(const MachineInstr &MI,
53 const MachineRegisterInfo &MRI) {
54 // If we can move an instruction, we can remove it. Otherwise, it has
55 // a side-effect of some sort.
56 bool SawStore = false;
57 if (!MI.isSafeToMove(/*AA=*/nullptr, SawStore))
58 return false;
59
60 // Instructions without side-effects are dead iff they only define dead vregs.
61 for (auto &MO : MI.operands()) {
62 if (!MO.isReg() || !MO.isDef())
63 continue;
64
65 unsigned Reg = MO.getReg();
66 // Keep Debug uses live: we don't want to have an effect on debug info.
67 if (TargetRegisterInfo::isPhysicalRegister(Reg) || !MRI.use_empty(Reg))
68 return false;
69 }
70 return true;
4871 }
4972
5073 bool InstructionSelect::runOnMachineFunction(MachineFunction &MF) {
118141
119142 DEBUG(dbgs() << "Selecting: \n " << MI);
120143
144 // We could have folded this instruction away already, making it dead.
145 // If so, erase it.
146 if (isTriviallyDead(MI, MRI)) {
147 DEBUG(dbgs() << "Is dead; erasing.\n");
148 MI.eraseFromParent();
149 continue;
150 }
151
121152 if (!ISel->select(MI)) {
122153 // FIXME: It would be nice to dump all inserted instructions. It's
123154 // not obvious how, esp. considering select() can insert after MI.
8282 %0(s32) = COPY %w0
8383 %1(s32) = COPY %w1
8484 %2(s32) = G_ADD %0, %1
85 %w0 = COPY %2(s32)
8586 ...
8687
8788 ---
111112 %0(s64) = COPY %x0
112113 %1(s64) = COPY %x1
113114 %2(s64) = G_ADD %0, %1
115 %x0 = COPY %2(s64)
114116 ...
115117
116118 ---
121123
122124 # CHECK: registers:
123125 # CHECK-NEXT: - { id: 0, class: gpr32sp }
124 # CHECK-NEXT: - { id: 1, class: gpr32 }
126 # CHECK-NEXT: - { id: 1, class: gpr }
125127 # CHECK-NEXT: - { id: 2, class: gpr32sp }
126128 registers:
127129 - { id: 0, class: gpr }
138140 %0(s32) = COPY %w0
139141 %1(s32) = G_CONSTANT i32 1
140142 %2(s32) = G_ADD %0, %1
143 %w0 = COPY %2(s32)
141144 ...
142145
143146 ---
148151
149152 # CHECK: registers:
150153 # CHECK-NEXT: - { id: 0, class: gpr64sp }
151 # CHECK-NEXT: - { id: 1, class: gpr64 }
154 # CHECK-NEXT: - { id: 1, class: gpr }
152155 # CHECK-NEXT: - { id: 2, class: gpr64sp }
153156 registers:
154157 - { id: 0, class: gpr }
165168 %0(s64) = COPY %x0
166169 %1(s64) = G_CONSTANT i32 1
167170 %2(s64) = G_ADD %0, %1
171 %x0 = COPY %2(s64)
168172 ...
169173
170174 ---
175179
176180 # CHECK: registers:
177181 # CHECK-NEXT: - { id: 0, class: gpr32sp }
178 # CHECK-NEXT: - { id: 1, class: gpr32 }
182 # CHECK-NEXT: - { id: 1, class: gpr }
179183 # CHECK-NEXT: - { id: 2, class: gpr32sp }
180184 registers:
181185 - { id: 0, class: gpr }
197201
198202 bb.1:
199203 %2(s32) = G_ADD %0, %1
204 %w0 = COPY %2(s32)
200205 ...
201206
202207 ---
226231 %0(s32) = COPY %w0
227232 %1(s32) = COPY %w1
228233 %2(s32) = G_SUB %0, %1
234 %w0 = COPY %2(s32)
229235 ...
230236
231237 ---
255261 %0(s64) = COPY %x0
256262 %1(s64) = COPY %x1
257263 %2(s64) = G_SUB %0, %1
264 %x0 = COPY %2(s64)
258265 ...
259266
260267 ---
284291 %0(s32) = COPY %w0
285292 %1(s32) = COPY %w1
286293 %2(s32) = G_OR %0, %1
294 %w0 = COPY %2(s32)
287295 ...
288296
289297 ---
313321 %0(s64) = COPY %x0
314322 %1(s64) = COPY %x1
315323 %2(s64) = G_OR %0, %1
324 %x0 = COPY %2(s64)
316325 ...
317326
318327 ---
344353 %0(<2 x s32>) = COPY %d0
345354 %1(<2 x s32>) = COPY %d1
346355 %2(<2 x s32>) = G_OR %0, %1
356 %d0 = COPY %2(<2 x s32>)
347357 ...
348358
349359 ---
373383 %0(s32) = COPY %w0
374384 %1(s32) = COPY %w1
375385 %2(s32) = G_AND %0, %1
386 %w0 = COPY %2(s32)
376387 ...
377388
378389 ---
402413 %0(s64) = COPY %x0
403414 %1(s64) = COPY %x1
404415 %2(s64) = G_AND %0, %1
416 %x0 = COPY %2(s64)
405417 ...
406418
407419 ---
431443 %0(s32) = COPY %w0
432444 %1(s32) = COPY %w1
433445 %2(s32) = G_SHL %0, %1
446 %w0 = COPY %2(s32)
434447 ...
435448
436449 ---
460473 %0(s64) = COPY %x0
461474 %1(s64) = COPY %x1
462475 %2(s64) = G_SHL %0, %1
476 %x0 = COPY %2(s64)
463477 ...
464478
465479 ---
489503 %0(s32) = COPY %w0
490504 %1(s32) = COPY %w1
491505 %2(s32) = G_LSHR %0, %1
506 %w0 = COPY %2(s32)
492507 ...
493508
494509 ---
518533 %0(s64) = COPY %x0
519534 %1(s64) = COPY %x1
520535 %2(s64) = G_LSHR %0, %1
536 %x0 = COPY %2(s64)
521537 ...
522538
523539 ---
547563 %0(s32) = COPY %w0
548564 %1(s32) = COPY %w1
549565 %2(s32) = G_ASHR %0, %1
566 %w0 = COPY %2(s32)
550567 ...
551568
552569 ---
576593 %0(s64) = COPY %x0
577594 %1(s64) = COPY %x1
578595 %2(s64) = G_ASHR %0, %1
596 %x0 = COPY %2(s64)
579597 ...
580598
581599 ---
606624 %0(s32) = COPY %w0
607625 %1(s32) = COPY %w1
608626 %2(s32) = G_MUL %0, %1
627 %w0 = COPY %2(s32)
609628 ...
610629
611630 ---
635654 %0(s64) = COPY %x0
636655 %1(s64) = COPY %x1
637656 %2(s64) = G_MUL %0, %1
657 %x0 = COPY %2(s64)
638658 ...
639659
640660 ---
663683 %1:gpr(s64) = COPY %x1
664684 %2:gpr(s64) = G_SMULH %0, %1
665685 %3:gpr(s64) = G_UMULH %0, %1
686 %x0 = COPY %2(s64)
687 %x0 = COPY %3(s64)
666688 ...
667689
668690 ---
692714 %0(s32) = COPY %w0
693715 %1(s32) = COPY %w1
694716 %2(s32) = G_SDIV %0, %1
717 %w0 = COPY %2(s32)
695718 ...
696719
697720 ---
721744 %0(s64) = COPY %x0
722745 %1(s64) = COPY %x1
723746 %2(s64) = G_SDIV %0, %1
747 %x0 = COPY %2(s64)
724748 ...
725749
726750 ---
750774 %0(s32) = COPY %w0
751775 %1(s32) = COPY %w1
752776 %2(s32) = G_UDIV %0, %1
777 %w0 = COPY %2(s32)
753778 ...
754779
755780 ---
779804 %0(s64) = COPY %x0
780805 %1(s64) = COPY %x1
781806 %2(s64) = G_UDIV %0, %1
807 %x0 = COPY %2(s64)
782808 ...
783809
784810 ---
808834 %0(s32) = COPY %s0
809835 %1(s32) = COPY %s1
810836 %2(s32) = G_FADD %0, %1
837 %s0 = COPY %2(s32)
811838 ...
812839
813840 ---
836863 %0(s64) = COPY %d0
837864 %1(s64) = COPY %d1
838865 %2(s64) = G_FADD %0, %1
866 %d0 = COPY %2(s64)
839867 ...
840868
841869 ---
864892 %0(s32) = COPY %s0
865893 %1(s32) = COPY %s1
866894 %2(s32) = G_FSUB %0, %1
895 %s0 = COPY %2(s32)
867896 ...
868897
869898 ---
892921 %0(s64) = COPY %d0
893922 %1(s64) = COPY %d1
894923 %2(s64) = G_FSUB %0, %1
924 %d0 = COPY %2(s64)
895925 ...
896926
897927 ---
920950 %0(s32) = COPY %s0
921951 %1(s32) = COPY %s1
922952 %2(s32) = G_FMUL %0, %1
953 %s0 = COPY %2(s32)
923954 ...
924955
925956 ---
948979 %0(s64) = COPY %d0
949980 %1(s64) = COPY %d1
950981 %2(s64) = G_FMUL %0, %1
982 %d0 = COPY %2(s64)
951983 ...
952984
953985 ---
9761008 %0(s32) = COPY %s0
9771009 %1(s32) = COPY %s1
9781010 %2(s32) = G_FDIV %0, %1
1011 %s0 = COPY %2(s32)
9791012 ...
9801013
9811014 ---
10041037 %0(s64) = COPY %d0
10051038 %1(s64) = COPY %d1
10061039 %2(s64) = G_FDIV %0, %1
1007 ...
1040 %d0 = COPY %2(s64)
1041 ...
3333
3434 %0(s32) = COPY %w0
3535 %1(s32) = G_BITCAST %0
36 %w0 = COPY %1(s32)
3637 ...
3738
3839 ---
5758
5859 %0(s32) = COPY %s0
5960 %1(s32) = G_BITCAST %0
61 %s0 = COPY %1(s32)
6062 ...
6163
6264 ---
8183
8284 %0(s32) = COPY %w0
8385 %1(s32) = G_BITCAST %0
86 %s0 = COPY %1(s32)
8487 ...
8588
8689 ---
105108
106109 %0(s32) = COPY %s0
107110 %1(s32) = G_BITCAST %0
111 %w0 = COPY %1(s32)
108112 ...
109113
110114 ---
129133
130134 %0(s64) = COPY %x0
131135 %1(s64) = G_BITCAST %0
136 %x0 = COPY %1(s64)
132137 ...
133138
134139 ---
153158
154159 %0(s64) = COPY %d0
155160 %1(s64) = G_BITCAST %0
161 %d0 = COPY %1(s64)
156162 ...
157163
158164 ---
176182
177183 %0(s64) = COPY %x0
178184 %1(s64) = G_BITCAST %0
185 %d0 = COPY %1(s64)
179186 ...
180187
181188 ---
200207
201208 %0(s64) = COPY %d0
202209 %1(s64) = G_BITCAST %0
203 ...
210 %x0 = COPY %1(s64)
211 ...
2222 body: |
2323 bb.0:
2424 %0(s32) = G_CONSTANT i32 42
25 %w0 = COPY %0(s32)
2526 ...
2627
2728 ---
3738 body: |
3839 bb.0:
3940 %0(s64) = G_CONSTANT i64 1234567890123
41 %x0 = COPY %0(s64)
4042 ...
4143
4244 ---
5355 body: |
5456 bb.0:
5557 %0(s32) = G_FCONSTANT float 3.5
58 %s0 = COPY %0(s32)
5659 ...
5760
5861 ---
6972 body: |
7073 bb.0:
7174 %0(s64) = G_FCONSTANT double 1.0
75 %d0 = COPY %0(s64)
7276 ...
4848
4949 %0(s64) = COPY %d0
5050 %1(s32) = G_FPTRUNC %0
51 %s0 = COPY %1(s32)
5152 ...
5253
5354 ---
7273
7374 %0(s32) = COPY %s0
7475 %1(s64) = G_FPEXT %0
76 %d0 = COPY %1(s64)
7577 ...
7678
7779 ---
9698
9799 %0(s32) = COPY %w0
98100 %1(s32) = G_SITOFP %0
101 %s0 = COPY %1(s32)
99102 ...
100103
101104 ---
120123
121124 %0(s64) = COPY %x0
122125 %1(s32) = G_SITOFP %0
126 %s0 = COPY %1(s32)
123127 ...
124128
125129 ---
144148
145149 %0(s32) = COPY %w0
146150 %1(s64) = G_SITOFP %0
151 %d0 = COPY %1(s64)
147152 ...
148153
149154 ---
168173
169174 %0(s64) = COPY %x0
170175 %1(s64) = G_SITOFP %0
176 %d0 = COPY %1(s64)
171177 ...
172178
173179 ---
192198
193199 %0(s32) = COPY %w0
194200 %1(s32) = G_UITOFP %0
201 %s0 = COPY %1(s32)
195202 ...
196203
197204 ---
216223
217224 %0(s64) = COPY %x0
218225 %1(s32) = G_UITOFP %0
226 %s0 = COPY %1(s32)
219227 ...
220228
221229 ---
240248
241249 %0(s32) = COPY %w0
242250 %1(s64) = G_UITOFP %0
251 %d0 = COPY %1(s64)
243252 ...
244253
245254 ---
264273
265274 %0(s64) = COPY %x0
266275 %1(s64) = G_UITOFP %0
276 %d0 = COPY %1(s64)
267277 ...
268278
269279 ---
288298
289299 %0(s32) = COPY %s0
290300 %1(s32) = G_FPTOSI %0
301 %w0 = COPY %1(s32)
291302 ...
292303
293304 ---
312323
313324 %0(s64) = COPY %d0
314325 %1(s32) = G_FPTOSI %0
326 %w0 = COPY %1(s32)
315327 ...
316328
317329 ---
336348
337349 %0(s32) = COPY %s0
338350 %1(s64) = G_FPTOSI %0
351 %x0 = COPY %1(s64)
339352 ...
340353
341354 ---
360373
361374 %0(s64) = COPY %d0
362375 %1(s64) = G_FPTOSI %0
376 %x0 = COPY %1(s64)
363377 ...
364378
365379 ---
384398
385399 %0(s32) = COPY %s0
386400 %1(s32) = G_FPTOUI %0
401 %w0 = COPY %1(s32)
387402 ...
388403
389404 ---
408423
409424 %0(s64) = COPY %d0
410425 %1(s32) = G_FPTOUI %0
426 %w0 = COPY %1(s32)
411427 ...
412428
413429 ---
432448
433449 %0(s32) = COPY %s0
434450 %1(s64) = G_FPTOUI %0
451 %x0 = COPY %1(s64)
435452 ...
436453
437454 ---
456473
457474 %0(s64) = COPY %d0
458475 %1(s64) = G_FPTOUI %0
459 ...
476 %x0 = COPY %1(s64)
477 ...
3838
3939 %0(s32) = COPY %w0
4040 %1(s64) = G_ANYEXT %0
41 %x0 = COPY %1(s64)
4142 ...
4243
4344 ---
6263
6364 %0(s8) = COPY %w0
6465 %1(s32) = G_ANYEXT %0
66 %w0 = COPY %1(s32)
6567 ...
6668
6769 ---
8890
8991 %0(s32) = COPY %w0
9092 %1(s64) = G_ZEXT %0
93 %x0 = COPY %1(s64)
9194 ...
9295
9396 ---
112115
113116 %0(s8) = COPY %w0
114117 %1(s32) = G_ZEXT %0
118 %w0 = COPY %1(s32)
115119 ...
116120
117121 ---
136140
137141 %0(s8) = COPY %w0
138142 %1(s16) = G_ZEXT %0
143 %w0 = COPY %1(s16)
139144 ...
140145
141146 ---
162167
163168 %0(s32) = COPY %w0
164169 %1(s64) = G_SEXT %0
170 %x0 = COPY %1(s64)
165171 ...
166172
167173 ---
186192
187193 %0(s8) = COPY %w0
188194 %1(s32) = G_SEXT %0
195 %w0 = COPY %1(s32)
189196 ...
190197
191198 ---
210217
211218 %0(s8) = COPY %w0
212219 %1(s16) = G_SEXT %0
213 ...
220 %w0 = COPY %1(s16)
221 ...
3030 liveins: %x0
3131 %0(s64) = COPY %x0
3232 %1(p0) = G_INTTOPTR %0
33 %x0 = COPY %1(p0)
3334 ...
3435
3536 ---
5253 liveins: %x0
5354 %0(p0) = COPY %x0
5455 %1(s64) = G_PTRTOINT %0
56 %x0 = COPY %1(s64)
5557 ...
5658
5759 ---
7476 liveins: %x0
7577 %0(p0) = COPY %x0
7678 %1(s32) = G_PTRTOINT %0
79 %w0 = COPY %1(s32)
7780 ...
7881
7982 ---
9699 liveins: %x0
97100 %0(p0) = COPY %x0
98101 %1(s16) = G_PTRTOINT %0
102 %w0 = COPY %1(s16)
99103 ...
100104
101105 ---
118122 liveins: %x0
119123 %0(p0) = COPY %x0
120124 %1(s8) = G_PTRTOINT %0
125 %w0 = COPY %1(s8)
121126 ...
122127
123128 ---
140145 liveins: %x0
141146 %0(p0) = COPY %x0
142147 %1(s1) = G_PTRTOINT %0
148 %w0 = COPY %1(s1)
143149 ...
3434
3535 %0(p0) = COPY %x0
3636 %1(s64) = G_LOAD %0 :: (load 8 from %ir.addr)
37
37 %x0 = COPY %1(s64)
3838 ...
3939
4040 ---
5959
6060 %0(p0) = COPY %x0
6161 %1(s32) = G_LOAD %0 :: (load 4 from %ir.addr)
62
62 %w0 = COPY %1(s32)
6363 ...
6464
6565 ---
8484
8585 %0(p0) = COPY %x0
8686 %1(s16) = G_LOAD %0 :: (load 2 from %ir.addr)
87
87 %w0 = COPY %1(s16)
8888 ...
8989
9090 ---
109109
110110 %0(p0) = COPY %x0
111111 %1(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
112
112 %w0 = COPY %1(s8)
113113 ...
114114
115115 ---
134134
135135 %0(p0) = COPY %x0
136136 %1(s64) = G_LOAD %0 :: (load 8 from %ir.addr)
137
137 %d0 = COPY %1(s64)
138138 ...
139139
140140 ---
159159
160160 %0(p0) = COPY %x0
161161 %1(s32) = G_LOAD %0 :: (load 4 from %ir.addr)
162
162 %s0 = COPY %1(s32)
163163 ...
164164
165165 ---
184184
185185 %0(p0) = COPY %x0
186186 %1(s16) = G_LOAD %0 :: (load 2 from %ir.addr)
187
187 %h0 = COPY %1(s16)
188188 ...
189189
190190 ---
209209
210210 %0(p0) = COPY %x0
211211 %1(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
212
213 ...
212 %b0 = COPY %1(s8)
213 ...
2828
2929 %0(s64) = COPY %x0
3030 %1(s32) = G_TRUNC %0
31 %w0 = COPY %1(s32)
3132 ...
3233
3334 ---
5152
5253 %0(s64) = COPY %x0
5354 %1(s8) = G_TRUNC %0
55 %w0 = COPY %1(s8)
5456 ...
5557
5658 ---
7476
7577 %0(s32) = COPY %w0
7678 %1(s1) = G_TRUNC %0
79 %w0 = COPY %1(s1)
7780 ...
3838 %0(s32) = COPY %w0
3939 %1(s32) = COPY %w1
4040 %2(s32) = G_XOR %0, %1
41 %w0 = COPY %2(s32)
4142 ...
4243
4344 ---
6768 %0(s64) = COPY %x0
6869 %1(s64) = COPY %x1
6970 %2(s64) = G_XOR %0, %1
71 %x0 = COPY %2(s64)
7072 ...
7173
7274 ---
7981
8082 # CHECK: registers:
8183 # CHECK-NEXT: - { id: 0, class: gpr32 }
82 # CHECK-NEXT: - { id: 1, class: gpr32 }
84 # CHECK-NEXT: - { id: 1, class: gpr }
8385 # CHECK-NEXT: - { id: 2, class: gpr32 }
8486 registers:
8587 - { id: 0, class: gpr }
9698 %0(s32) = COPY %w0
9799 %1(s32) = G_CONSTANT i64 -1
98100 %2(s32) = G_XOR %0, %1
101 %w0 = COPY %2(s32)
99102 ...
100103
101104 ---
107110
108111 # CHECK: registers:
109112 # CHECK-NEXT: - { id: 0, class: gpr64 }
110 # CHECK-NEXT: - { id: 1, class: gpr64 }
113 # CHECK-NEXT: - { id: 1, class: gpr }
111114 # CHECK-NEXT: - { id: 2, class: gpr64 }
112115 registers:
113116 - { id: 0, class: gpr }
124127 %0(s64) = COPY %x0
125128 %1(s64) = G_CONSTANT i64 -1
126129 %2(s64) = G_XOR %0, %1
130 %x0 = COPY %2(s64)
127131 ...
128132
129133 ---
135139
136140 # CHECK: registers:
137141 # CHECK-NEXT: - { id: 0, class: gpr32 }
138 # CHECK-NEXT: - { id: 1, class: gpr32 }
142 # CHECK-NEXT: - { id: 1, class: gpr }
139143 # CHECK-NEXT: - { id: 2, class: gpr32 }
140144 registers:
141145 - { id: 0, class: gpr }
156160 bb.1:
157161 %0(s32) = COPY %w0
158162 %2(s32) = G_XOR %0, %1
163 %w0 = COPY %2(s32)
159164 ...
4646 body: |
4747 bb.0:
4848 %0(p0) = G_FRAME_INDEX %stack.0.ptr0
49 %x0 = COPY %0(p0)
4950 ...
5051
5152 ---
6768 %0(p0) = COPY %x0
6869 %1(s64) = G_CONSTANT i64 42
6970 %2(p0) = G_GEP %0, %1(s64)
71 %x0 = COPY %2(p0)
7072 ...
7173
7274 ---
8284 liveins: %x0
8385 %0:gpr(p0) = COPY %x0
8486 %1:gpr(p0) = G_PTR_MASK %0, 3
87 %x0 = COPY %1(p0)
8588 ...
8689
8790 ---
100103 body: |
101104 bb.0:
102105 %0(p0) = G_GLOBAL_VALUE @var_local
106 %x0 = COPY %0(p0)
103107 ...
104108
105109 ---
117121 body: |
118122 bb.0:
119123 %0(p0) = G_GLOBAL_VALUE @var_got
124 %x0 = COPY %0(p0)
120125 ...
121126
122127 ---
156161
157162 %0(s32) = COPY %w0
158163 %1(s1) = G_ICMP intpred(eq), %0, %0
164 %w0 = COPY %1(s1)
159165
160166 %2(s64) = COPY %x0
161167 %3(s1) = G_ICMP intpred(uge), %2, %2
168 %w0 = COPY %3(s1)
162169
163170 %4(p0) = COPY %x0
164171 %5(s1) = G_ICMP intpred(ne), %4, %4
172 %w0 = COPY %5(s1)
165173 ...
166174
167175 ---
198206
199207 %0(s32) = COPY %s0
200208 %1(s1) = G_FCMP floatpred(one), %0, %0
209 %w0 = COPY %1(s1)
201210
202211 %2(s64) = COPY %d0
203212 %3(s1) = G_FCMP floatpred(uge), %2, %2
213 %w0 = COPY %3(s1)
204214
205215 ...
206216
286296 %1(s32) = COPY %w1
287297 %2(s32) = COPY %w2
288298 %3(s32) = G_SELECT %0, %1, %2
299 %w0 = COPY %3(s32)
289300
290301 %4(s64) = COPY %x0
291302 %5(s64) = COPY %x1
292303 %6(s64) = G_SELECT %0, %4, %5
304 %x0 = COPY %6(s64)
293305
294306 %7(p0) = COPY %x0
295307 %8(p0) = COPY %x1
296308 %9(p0) = G_SELECT %0, %7, %8
297 ...
309 %x0 = COPY %9(p0)
310 ...
2121
2222 %0:vgpr(p1) = COPY %vgpr0_vgpr1
2323 %1:vgpr(s32) = G_LOAD %0 :: (load 4 from %ir.global0)
24 %vgpr0 = COPY %1
2425
2526 ...
2627 ---
2424 # VI: S_LOAD_DWORD_IMM [[PTR]], 1020, 0
2525
2626 # Immediate overflow for SI
27 # FIXME: The immediate gets selected twice, once into the
28 # S_LOAD_DWORD instruction and once just as a normal constat.
29 # SI: S_MOV_B32 1024
3027 # SI: [[K1024:%[0-9]+]] = S_MOV_B32 1024
3128 # SI: S_LOAD_DWORD_SGPR [[PTR]], [[K1024]], 0
3229 # CI: S_LOAD_DWORD_IMM_ci [[PTR]], 256, 0
3330 # VI: S_LOAD_DWORD_IMM [[PTR]], 1024, 0
3431
3532 # Max immediate offset for VI
36 # SI: S_MOV_B32 1048572
3733 # SI: [[K1048572:%[0-9]+]] = S_MOV_B32 1048572
3834 # CI: S_LOAD_DWORD_IMM_ci [[PTR]], 262143
3935 # VI: S_LOAD_DWORD_IMM [[PTR]], 1048572
4036
4137 #
4238 # Immediate overflow for VI
43 # FIXME: The immediate gets selected twice, once into the
44 # S_LOAD_DWORD instruction and once just as a normal constat.
45 # SIVI: S_MOV_B32 1048576
4639 # SIVI: [[K1048576:%[0-9]+]] = S_MOV_B32 1048576
4740 # SIVI: S_LOAD_DWORD_SGPR [[PTR]], [[K1048576]], 0
4841 # CI: S_LOAD_DWORD_IMM_ci [[PTR]], 262144, 0
7568 # GCN: S_LOAD_DWORD_IMM [[ADD_PTR]], 0, 0
7669
7770 # Max 32-bit byte offset
78 # FIXME: The immediate gets selected twice, once into the
79 # S_LOAD_DWORD instruction and once just as a normal constat.
80 # SIVI: S_MOV_B32 4294967292
8171 # SIVI: [[K4294967292:%[0-9]+]] = S_MOV_B32 4294967292
8272 # SIVI: S_LOAD_DWORD_SGPR [[PTR]], [[K4294967292]], 0
8373 # CI: S_LOAD_DWORD_IMM_ci [[PTR]], 1073741823, 0
10595 %1:sgpr(s64) = G_CONSTANT i64 4
10696 %2:sgpr(p2) = G_GEP %0, %1
10797 %3:sgpr(s32) = G_LOAD %2 :: (load 4 from %ir.const0)
98 %sgpr0 = COPY %3
10899
109100 %4:sgpr(s64) = G_CONSTANT i64 1020
110101 %5:sgpr(p2) = G_GEP %0, %4
111102 %6:sgpr(s32) = G_LOAD %5 :: (load 4 from %ir.const0)
103 %sgpr0 = COPY %6
112104
113105 %7:sgpr(s64) = G_CONSTANT i64 1024
114106 %8:sgpr(p2) = G_GEP %0, %7
115107 %9:sgpr(s32) = G_LOAD %8 :: (load 4 from %ir.const0)
108 %sgpr0 = COPY %9
116109
117110 %10:sgpr(s64) = G_CONSTANT i64 1048572
118111 %11:sgpr(p2) = G_GEP %0, %10
119112 %12:sgpr(s32) = G_LOAD %11 :: (load 4 from %ir.const0)
113 %sgpr0 = COPY %12
120114
121115 %13:sgpr(s64) = G_CONSTANT i64 1048576
122116 %14:sgpr(p2) = G_GEP %0, %13
123117 %15:sgpr(s32) = G_LOAD %14 :: (load 4 from %ir.const0)
118 %sgpr0 = COPY %15
124119
125120 %16:sgpr(s64) = G_CONSTANT i64 17179869180
126121 %17:sgpr(p2) = G_GEP %0, %16
127122 %18:sgpr(s32) = G_LOAD %17 :: (load 4 from %ir.const0)
123 %sgpr0 = COPY %18
128124
129125 %19:sgpr(s64) = G_CONSTANT i64 17179869184
130126 %20:sgpr(p2) = G_GEP %0, %19
131127 %21:sgpr(s32) = G_LOAD %20 :: (load 4 from %ir.const0)
128 %sgpr0 = COPY %21
132129
133130 %22:sgpr(s64) = G_CONSTANT i64 4294967292
134131 %23:sgpr(p2) = G_GEP %0, %22
135132 %24:sgpr(s32) = G_LOAD %23 :: (load 4 from %ir.const0)
133 %sgpr0 = COPY %24
136134
137135 %25:sgpr(s64) = G_CONSTANT i64 4294967296
138136 %26:sgpr(p2) = G_GEP %0, %25
139137 %27:sgpr(s32) = G_LOAD %26 :: (load 4 from %ir.const0)
138 %sgpr0 = COPY %27
140139
141140 ...
142141 ---
325325 ; CHECK: [[FI32VREG:%[0-9]+]] = ADDri %fixed-stack.[[FI32]], 0, 14, _, _
326326
327327 %1(s32) = G_LOAD %0(p0) :: (load 4)
328 ; CHECK: {{%[0-9]+}} = LDRi12 [[FI32VREG]], 0, 14, _
328 ; CHECK: [[LD32VREG:%[0-9]+]] = LDRi12 [[FI32VREG]], 0, 14, _
329
330 %r0 = COPY %1
331 ; CHECK: %r0 = COPY [[LD32VREG]]
329332
330333 %2(p0) = G_FRAME_INDEX %fixed-stack.0
331334 ; CHECK: [[FI1VREG:%[0-9]+]] = ADDri %fixed-stack.[[FI1]], 0, 14, _, _
332335
333336 %3(s1) = G_LOAD %2(p0) :: (load 1)
334 ; CHECK: {{%[0-9]+}} = LDRBi12 [[FI1VREG]], 0, 14, _
337 ; CHECK: [[LD1VREG:%[0-9]+]] = LDRBi12 [[FI1VREG]], 0, 14, _
338
339 %r0 = COPY %3
340 ; CHECK: %r0 = COPY [[LD1VREG]]
335341
336342 BX_RET 14, _
337343 ; CHECK: BX_RET 14, _
8686 %0(s64) = COPY %rdi
8787 %1(s64) = COPY %rsi
8888 %2(s64) = G_ADD %0, %1
89 %rax = COPY %2(s64)
8990
9091 ...
9192
111112 %0(s32) = COPY %edi
112113 %1(s32) = COPY %esi
113114 %2(s32) = G_ADD %0, %1
115 %rax = COPY %2(s32)
114116
115117 ...
116118
136138 %0(s64) = COPY %rdi
137139 %1(s64) = COPY %rsi
138140 %2(s64) = G_SUB %0, %1
141 %rax = COPY %2(s64)
139142
140143 ...
141144
161164 %0(s32) = COPY %edi
162165 %1(s32) = COPY %esi
163166 %2(s32) = G_SUB %0, %1
167 %rax = COPY %2(s32)
164168
165169 ...
166170