blob: a1aa841eccc2285003c226514cbc2207504c0d3e [file] [log] [blame]
Bill Schmidtfe723b92015-04-27 19:57:34 +00001//===----------- PPCVSXSwapRemoval.cpp - Remove VSX LE Swaps -------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===---------------------------------------------------------------------===//
9//
10// This pass analyzes vector computations and removes unnecessary
11// doubleword swaps (xxswapd instructions). This pass is performed
12// only for little-endian VSX code generation.
13//
14// For this specific case, loads and stores of v4i32, v4f32, v2i64,
15// and v2f64 vectors are inefficient. These are implemented using
16// the lxvd2x and stxvd2x instructions, which invert the order of
17// doublewords in a vector register. Thus code generation inserts
18// an xxswapd after each such load, and prior to each such store.
19//
20// The extra xxswapd instructions reduce performance. The purpose
21// of this pass is to reduce the number of xxswapd instructions
22// required for correctness.
23//
24// The primary insight is that much code that operates on vectors
25// does not care about the relative order of elements in a register,
26// so long as the correct memory order is preserved. If we have a
27// computation where all input values are provided by lxvd2x/xxswapd,
28// all outputs are stored using xxswapd/lxvd2x, and all intermediate
29// computations are lane-insensitive (independent of element order),
30// then all the xxswapd instructions associated with the loads and
31// stores may be removed without changing observable semantics.
32//
33// This pass uses standard equivalence class infrastructure to create
34// maximal webs of computations fitting the above description. Each
35// such web is then optimized by removing its unnecessary xxswapd
36// instructions.
37//
38// There are some lane-sensitive operations for which we can still
39// permit the optimization, provided we modify those operations
40// accordingly. Such operations are identified as using "special
41// handling" within this module.
42//
43//===---------------------------------------------------------------------===//
44
45#include "PPCInstrInfo.h"
46#include "PPC.h"
47#include "PPCInstrBuilder.h"
48#include "PPCTargetMachine.h"
49#include "llvm/ADT/DenseMap.h"
50#include "llvm/ADT/EquivalenceClasses.h"
51#include "llvm/CodeGen/MachineFunctionPass.h"
52#include "llvm/CodeGen/MachineInstrBuilder.h"
53#include "llvm/CodeGen/MachineRegisterInfo.h"
54#include "llvm/Support/Debug.h"
55#include "llvm/Support/Format.h"
56#include "llvm/Support/raw_ostream.h"
57
58using namespace llvm;
59
60#define DEBUG_TYPE "ppc-vsx-swaps"
61
62namespace llvm {
63 void initializePPCVSXSwapRemovalPass(PassRegistry&);
64}
65
66namespace {
67
68// A PPCVSXSwapEntry is created for each machine instruction that
69// is relevant to a vector computation.
70struct PPCVSXSwapEntry {
71 // Pointer to the instruction.
72 MachineInstr *VSEMI;
73
74 // Unique ID (position in the swap vector).
75 int VSEId;
76
77 // Attributes of this node.
78 unsigned int IsLoad : 1;
79 unsigned int IsStore : 1;
80 unsigned int IsSwap : 1;
81 unsigned int MentionsPhysVR : 1;
Bill Schmidtfe723b92015-04-27 19:57:34 +000082 unsigned int IsSwappable : 1;
Bill Schmidt15deb802015-07-13 22:58:19 +000083 unsigned int MentionsPartialVR : 1;
Bill Schmidtfe723b92015-04-27 19:57:34 +000084 unsigned int SpecialHandling : 3;
85 unsigned int WebRejected : 1;
86 unsigned int WillRemove : 1;
87};
88
89enum SHValues {
90 SH_NONE = 0,
Bill Schmidtfe723b92015-04-27 19:57:34 +000091 SH_EXTRACT,
92 SH_INSERT,
93 SH_NOSWAP_LD,
94 SH_NOSWAP_ST,
Bill Schmidt15deb802015-07-13 22:58:19 +000095 SH_SPLAT,
96 SH_XXPERMDI,
Bill Schmidt2be80542015-07-21 21:40:17 +000097 SH_COPYWIDEN
Bill Schmidtfe723b92015-04-27 19:57:34 +000098};
99
100struct PPCVSXSwapRemoval : public MachineFunctionPass {
101
102 static char ID;
103 const PPCInstrInfo *TII;
104 MachineFunction *MF;
105 MachineRegisterInfo *MRI;
106
107 // Swap entries are allocated in a vector for better performance.
108 std::vector<PPCVSXSwapEntry> SwapVector;
109
110 // A mapping is maintained between machine instructions and
111 // their swap entries. The key is the address of the MI.
112 DenseMap<MachineInstr*, int> SwapMap;
113
114 // Equivalence classes are used to gather webs of related computation.
115 // Swap entries are represented by their VSEId fields.
116 EquivalenceClasses<int> *EC;
117
118 PPCVSXSwapRemoval() : MachineFunctionPass(ID) {
119 initializePPCVSXSwapRemovalPass(*PassRegistry::getPassRegistry());
120 }
121
122private:
123 // Initialize data structures.
124 void initialize(MachineFunction &MFParm);
125
126 // Walk the machine instructions to gather vector usage information.
127 // Return true iff vector mentions are present.
128 bool gatherVectorInstructions();
129
130 // Add an entry to the swap vector and swap map.
131 int addSwapEntry(MachineInstr *MI, PPCVSXSwapEntry &SwapEntry);
132
133 // Hunt backwards through COPY and SUBREG_TO_REG chains for a
134 // source register. VecIdx indicates the swap vector entry to
135 // mark as mentioning a physical register if the search leads
136 // to one.
137 unsigned lookThruCopyLike(unsigned SrcReg, unsigned VecIdx);
138
139 // Generate equivalence classes for related computations (webs).
140 void formWebs();
141
142 // Analyze webs and determine those that cannot be optimized.
143 void recordUnoptimizableWebs();
144
145 // Record which swap instructions can be safely removed.
146 void markSwapsForRemoval();
147
148 // Remove swaps and update other instructions requiring special
149 // handling. Return true iff any changes are made.
150 bool removeSwaps();
151
Bill Schmidt2be80542015-07-21 21:40:17 +0000152 // Insert a swap instruction from SrcReg to DstReg at the given
153 // InsertPoint.
154 void insertSwap(MachineInstr *MI, MachineBasicBlock::iterator InsertPoint,
155 unsigned DstReg, unsigned SrcReg);
156
Bill Schmidtfe723b92015-04-27 19:57:34 +0000157 // Update instructions requiring special handling.
158 void handleSpecialSwappables(int EntryIdx);
159
160 // Dump a description of the entries in the swap vector.
161 void dumpSwapVector();
162
163 // Return true iff the given register is in the given class.
164 bool isRegInClass(unsigned Reg, const TargetRegisterClass *RC) {
165 if (TargetRegisterInfo::isVirtualRegister(Reg))
166 return RC->hasSubClassEq(MRI->getRegClass(Reg));
Alexander Kornienko175a7cb2015-12-28 13:38:42 +0000167 return RC->contains(Reg);
Bill Schmidtfe723b92015-04-27 19:57:34 +0000168 }
169
170 // Return true iff the given register is a full vector register.
171 bool isVecReg(unsigned Reg) {
172 return (isRegInClass(Reg, &PPC::VSRCRegClass) ||
173 isRegInClass(Reg, &PPC::VRRCRegClass));
174 }
175
Bill Schmidt15deb802015-07-13 22:58:19 +0000176 // Return true iff the given register is a partial vector register.
177 bool isScalarVecReg(unsigned Reg) {
178 return (isRegInClass(Reg, &PPC::VSFRCRegClass) ||
179 isRegInClass(Reg, &PPC::VSSRCRegClass));
180 }
181
182 // Return true iff the given register mentions all or part of a
183 // vector register. Also sets Partial to true if the mention
184 // is for just the floating-point register overlap of the register.
185 bool isAnyVecReg(unsigned Reg, bool &Partial) {
186 if (isScalarVecReg(Reg))
187 Partial = true;
188 return isScalarVecReg(Reg) || isVecReg(Reg);
189 }
190
Bill Schmidtfe723b92015-04-27 19:57:34 +0000191public:
192 // Main entry point for this pass.
193 bool runOnMachineFunction(MachineFunction &MF) override {
Andrew Kaylor289bd5f2016-04-27 19:39:32 +0000194 if (skipFunction(*MF.getFunction()))
195 return false;
196
Bill Schmidtfe723b92015-04-27 19:57:34 +0000197 // If we don't have VSX on the subtarget, don't do anything.
198 const PPCSubtarget &STI = MF.getSubtarget<PPCSubtarget>();
199 if (!STI.hasVSX())
200 return false;
201
202 bool Changed = false;
203 initialize(MF);
204
205 if (gatherVectorInstructions()) {
206 formWebs();
207 recordUnoptimizableWebs();
208 markSwapsForRemoval();
209 Changed = removeSwaps();
210 }
211
212 // FIXME: See the allocation of EC in initialize().
213 delete EC;
214 return Changed;
215 }
216};
217
218// Initialize data structures for this pass. In particular, clear the
219// swap vector and allocate the equivalence class mapping before
220// processing each function.
221void PPCVSXSwapRemoval::initialize(MachineFunction &MFParm) {
222 MF = &MFParm;
223 MRI = &MF->getRegInfo();
Bill Schmidt8ed7cec2015-11-02 22:43:57 +0000224 TII = MF->getSubtarget<PPCSubtarget>().getInstrInfo();
Bill Schmidtfe723b92015-04-27 19:57:34 +0000225
226 // An initial vector size of 256 appears to work well in practice.
227 // Small/medium functions with vector content tend not to incur a
228 // reallocation at this size. Three of the vector tests in
229 // projects/test-suite reallocate, which seems like a reasonable rate.
230 const int InitialVectorSize(256);
231 SwapVector.clear();
232 SwapVector.reserve(InitialVectorSize);
233
234 // FIXME: Currently we allocate EC each time because we don't have
235 // access to the set representation on which to call clear(). Should
236 // consider adding a clear() method to the EquivalenceClasses class.
237 EC = new EquivalenceClasses<int>;
238}
239
240// Create an entry in the swap vector for each instruction that mentions
241// a full vector register, recording various characteristics of the
242// instructions there.
243bool PPCVSXSwapRemoval::gatherVectorInstructions() {
244 bool RelevantFunction = false;
245
246 for (MachineBasicBlock &MBB : *MF) {
247 for (MachineInstr &MI : MBB) {
248
Bill Schmidt32fd1892015-08-24 19:27:27 +0000249 if (MI.isDebugValue())
250 continue;
251
Bill Schmidtfe723b92015-04-27 19:57:34 +0000252 bool RelevantInstr = false;
Bill Schmidt15deb802015-07-13 22:58:19 +0000253 bool Partial = false;
Bill Schmidtfe723b92015-04-27 19:57:34 +0000254
255 for (const MachineOperand &MO : MI.operands()) {
256 if (!MO.isReg())
257 continue;
258 unsigned Reg = MO.getReg();
Bill Schmidt15deb802015-07-13 22:58:19 +0000259 if (isAnyVecReg(Reg, Partial)) {
Bill Schmidtfe723b92015-04-27 19:57:34 +0000260 RelevantInstr = true;
Bill Schmidtfe723b92015-04-27 19:57:34 +0000261 break;
262 }
263 }
264
265 if (!RelevantInstr)
266 continue;
267
268 RelevantFunction = true;
269
270 // Create a SwapEntry initialized to zeros, then fill in the
271 // instruction and ID fields before pushing it to the back
272 // of the swap vector.
273 PPCVSXSwapEntry SwapEntry{};
274 int VecIdx = addSwapEntry(&MI, SwapEntry);
275
Bill Schmidtfe723b92015-04-27 19:57:34 +0000276 switch(MI.getOpcode()) {
277 default:
278 // Unless noted otherwise, an instruction is considered
279 // safe for the optimization. There are a large number of
280 // such true-SIMD instructions (all vector math, logical,
Bill Schmidt15deb802015-07-13 22:58:19 +0000281 // select, compare, etc.). However, if the instruction
282 // mentions a partial vector register and does not have
283 // special handling defined, it is not swappable.
284 if (Partial)
285 SwapVector[VecIdx].MentionsPartialVR = 1;
286 else
287 SwapVector[VecIdx].IsSwappable = 1;
Bill Schmidtfe723b92015-04-27 19:57:34 +0000288 break;
Bill Schmidt7c691fe2015-07-02 17:03:06 +0000289 case PPC::XXPERMDI: {
Bill Schmidtfe723b92015-04-27 19:57:34 +0000290 // This is a swap if it is of the form XXPERMDI t, s, s, 2.
291 // Unfortunately, MachineCSE ignores COPY and SUBREG_TO_REG, so we
292 // can also see XXPERMDI t, SUBREG_TO_REG(s), SUBREG_TO_REG(s), 2,
293 // for example. We have to look through chains of COPY and
294 // SUBREG_TO_REG to find the real source value for comparison.
295 // If the real source value is a physical register, then mark the
296 // XXPERMDI as mentioning a physical register.
Bill Schmidt7c691fe2015-07-02 17:03:06 +0000297 int immed = MI.getOperand(3).getImm();
298 if (immed == 2) {
Bill Schmidtfe723b92015-04-27 19:57:34 +0000299 unsigned trueReg1 = lookThruCopyLike(MI.getOperand(1).getReg(),
300 VecIdx);
301 unsigned trueReg2 = lookThruCopyLike(MI.getOperand(2).getReg(),
302 VecIdx);
303 if (trueReg1 == trueReg2)
304 SwapVector[VecIdx].IsSwap = 1;
Bill Schmidt15deb802015-07-13 22:58:19 +0000305 else {
306 // We can still handle these if the two registers are not
307 // identical, by adjusting the form of the XXPERMDI.
308 SwapVector[VecIdx].IsSwappable = 1;
309 SwapVector[VecIdx].SpecialHandling = SHValues::SH_XXPERMDI;
310 }
Bill Schmidt7c691fe2015-07-02 17:03:06 +0000311 // This is a doubleword splat if it is of the form
312 // XXPERMDI t, s, s, 0 or XXPERMDI t, s, s, 3. As above we
313 // must look through chains of copy-likes to find the source
314 // register. We turn off the marking for mention of a physical
315 // register, because splatting it is safe; the optimization
Bill Schmidt15deb802015-07-13 22:58:19 +0000316 // will not swap the value in the physical register. Whether
317 // or not the two input registers are identical, we can handle
318 // these by adjusting the form of the XXPERMDI.
319 } else if (immed == 0 || immed == 3) {
320
321 SwapVector[VecIdx].IsSwappable = 1;
322 SwapVector[VecIdx].SpecialHandling = SHValues::SH_XXPERMDI;
323
Bill Schmidt7c691fe2015-07-02 17:03:06 +0000324 unsigned trueReg1 = lookThruCopyLike(MI.getOperand(1).getReg(),
325 VecIdx);
326 unsigned trueReg2 = lookThruCopyLike(MI.getOperand(2).getReg(),
327 VecIdx);
Bill Schmidt15deb802015-07-13 22:58:19 +0000328 if (trueReg1 == trueReg2)
Bill Schmidt7c691fe2015-07-02 17:03:06 +0000329 SwapVector[VecIdx].MentionsPhysVR = 0;
Bill Schmidt15deb802015-07-13 22:58:19 +0000330
331 } else {
332 // We can still handle these by adjusting the form of the XXPERMDI.
333 SwapVector[VecIdx].IsSwappable = 1;
334 SwapVector[VecIdx].SpecialHandling = SHValues::SH_XXPERMDI;
Bill Schmidt7c691fe2015-07-02 17:03:06 +0000335 }
Bill Schmidtfe723b92015-04-27 19:57:34 +0000336 break;
Bill Schmidt7c691fe2015-07-02 17:03:06 +0000337 }
Bill Schmidtfe723b92015-04-27 19:57:34 +0000338 case PPC::LVX:
339 // Non-permuting loads are currently unsafe. We can use special
340 // handling for this in the future. By not marking these as
341 // IsSwap, we ensure computations containing them will be rejected
342 // for now.
343 SwapVector[VecIdx].IsLoad = 1;
344 break;
345 case PPC::LXVD2X:
346 case PPC::LXVW4X:
347 // Permuting loads are marked as both load and swap, and are
348 // safe for optimization.
349 SwapVector[VecIdx].IsLoad = 1;
350 SwapVector[VecIdx].IsSwap = 1;
351 break;
Bill Schmidt2be80542015-07-21 21:40:17 +0000352 case PPC::LXSDX:
353 case PPC::LXSSPX:
354 // A load of a floating-point value into the high-order half of
355 // a vector register is safe, provided that we introduce a swap
356 // following the load, which will be done by the SUBREG_TO_REG
357 // support. So just mark these as safe.
358 SwapVector[VecIdx].IsLoad = 1;
359 SwapVector[VecIdx].IsSwappable = 1;
360 break;
Bill Schmidtfe723b92015-04-27 19:57:34 +0000361 case PPC::STVX:
362 // Non-permuting stores are currently unsafe. We can use special
363 // handling for this in the future. By not marking these as
364 // IsSwap, we ensure computations containing them will be rejected
365 // for now.
366 SwapVector[VecIdx].IsStore = 1;
367 break;
368 case PPC::STXVD2X:
369 case PPC::STXVW4X:
370 // Permuting stores are marked as both store and swap, and are
371 // safe for optimization.
372 SwapVector[VecIdx].IsStore = 1;
373 SwapVector[VecIdx].IsSwap = 1;
374 break;
Bill Schmidtfe723b92015-04-27 19:57:34 +0000375 case PPC::COPY:
376 // These are fine provided they are moving between full vector
377 // register classes.
378 if (isVecReg(MI.getOperand(0).getReg()) &&
379 isVecReg(MI.getOperand(1).getReg()))
380 SwapVector[VecIdx].IsSwappable = 1;
Bill Schmidt15deb802015-07-13 22:58:19 +0000381 // If we have a copy from one scalar floating-point register
382 // to another, we can accept this even if it is a physical
383 // register. The only way this gets involved is if it feeds
384 // a SUBREG_TO_REG, which is handled by introducing a swap.
385 else if (isScalarVecReg(MI.getOperand(0).getReg()) &&
386 isScalarVecReg(MI.getOperand(1).getReg()))
387 SwapVector[VecIdx].IsSwappable = 1;
Bill Schmidtfe723b92015-04-27 19:57:34 +0000388 break;
Bill Schmidt15deb802015-07-13 22:58:19 +0000389 case PPC::SUBREG_TO_REG: {
390 // These are fine provided they are moving between full vector
391 // register classes. If they are moving from a scalar
392 // floating-point class to a vector class, we can handle those
393 // as well, provided we introduce a swap. It is generally the
394 // case that we will introduce fewer swaps than we remove, but
395 // (FIXME) a cost model could be used. However, introduced
396 // swaps could potentially be CSEd, so this is not trivial.
397 if (isVecReg(MI.getOperand(0).getReg()) &&
398 isVecReg(MI.getOperand(2).getReg()))
399 SwapVector[VecIdx].IsSwappable = 1;
400 else if (isVecReg(MI.getOperand(0).getReg()) &&
401 isScalarVecReg(MI.getOperand(2).getReg())) {
402 SwapVector[VecIdx].IsSwappable = 1;
Bill Schmidt2be80542015-07-21 21:40:17 +0000403 SwapVector[VecIdx].SpecialHandling = SHValues::SH_COPYWIDEN;
Bill Schmidt15deb802015-07-13 22:58:19 +0000404 }
405 break;
406 }
Bill Schmidtfe723b92015-04-27 19:57:34 +0000407 case PPC::VSPLTB:
408 case PPC::VSPLTH:
409 case PPC::VSPLTW:
Nemanja Ivanovic1a2b2f02016-05-04 16:04:02 +0000410 case PPC::XXSPLTW:
Bill Schmidtfe723b92015-04-27 19:57:34 +0000411 // Splats are lane-sensitive, but we can use special handling
Nemanja Ivanovic1a2b2f02016-05-04 16:04:02 +0000412 // to adjust the source lane for the splat.
Bill Schmidt5fe2e252015-05-06 15:40:46 +0000413 SwapVector[VecIdx].IsSwappable = 1;
Bill Schmidtfe723b92015-04-27 19:57:34 +0000414 SwapVector[VecIdx].SpecialHandling = SHValues::SH_SPLAT;
415 break;
416 // The presence of the following lane-sensitive operations in a
417 // web will kill the optimization, at least for now. For these
418 // we do nothing, causing the optimization to fail.
419 // FIXME: Some of these could be permitted with special handling,
420 // and will be phased in as time permits.
421 // FIXME: There is no simple and maintainable way to express a set
422 // of opcodes having a common attribute in TableGen. Should this
423 // change, this is a prime candidate to use such a mechanism.
424 case PPC::INLINEASM:
425 case PPC::EXTRACT_SUBREG:
426 case PPC::INSERT_SUBREG:
427 case PPC::COPY_TO_REGCLASS:
428 case PPC::LVEBX:
429 case PPC::LVEHX:
430 case PPC::LVEWX:
431 case PPC::LVSL:
432 case PPC::LVSR:
433 case PPC::LVXL:
Bill Schmidtfe723b92015-04-27 19:57:34 +0000434 case PPC::STVEBX:
435 case PPC::STVEHX:
436 case PPC::STVEWX:
437 case PPC::STVXL:
Bill Schmidt2be80542015-07-21 21:40:17 +0000438 // We can handle STXSDX and STXSSPX similarly to LXSDX and LXSSPX,
439 // by adding special handling for narrowing copies as well as
440 // widening ones. However, I've experimented with this, and in
441 // practice we currently do not appear to use STXSDX fed by
442 // a narrowing copy from a full vector register. Since I can't
443 // generate any useful test cases, I've left this alone for now.
Bill Schmidtfe723b92015-04-27 19:57:34 +0000444 case PPC::STXSDX:
Bill Schmidt2be80542015-07-21 21:40:17 +0000445 case PPC::STXSSPX:
Bill Schmidtfe723b92015-04-27 19:57:34 +0000446 case PPC::VCIPHER:
447 case PPC::VCIPHERLAST:
448 case PPC::VMRGHB:
449 case PPC::VMRGHH:
450 case PPC::VMRGHW:
451 case PPC::VMRGLB:
452 case PPC::VMRGLH:
453 case PPC::VMRGLW:
454 case PPC::VMULESB:
455 case PPC::VMULESH:
456 case PPC::VMULESW:
457 case PPC::VMULEUB:
458 case PPC::VMULEUH:
459 case PPC::VMULEUW:
460 case PPC::VMULOSB:
461 case PPC::VMULOSH:
462 case PPC::VMULOSW:
463 case PPC::VMULOUB:
464 case PPC::VMULOUH:
465 case PPC::VMULOUW:
466 case PPC::VNCIPHER:
467 case PPC::VNCIPHERLAST:
468 case PPC::VPERM:
469 case PPC::VPERMXOR:
470 case PPC::VPKPX:
471 case PPC::VPKSHSS:
472 case PPC::VPKSHUS:
Bill Schmidt5ed84cd2015-05-16 01:02:12 +0000473 case PPC::VPKSDSS:
474 case PPC::VPKSDUS:
Bill Schmidtfe723b92015-04-27 19:57:34 +0000475 case PPC::VPKSWSS:
476 case PPC::VPKSWUS:
Bill Schmidt5ed84cd2015-05-16 01:02:12 +0000477 case PPC::VPKUDUM:
478 case PPC::VPKUDUS:
Bill Schmidtfe723b92015-04-27 19:57:34 +0000479 case PPC::VPKUHUM:
480 case PPC::VPKUHUS:
481 case PPC::VPKUWUM:
482 case PPC::VPKUWUS:
483 case PPC::VPMSUMB:
484 case PPC::VPMSUMD:
485 case PPC::VPMSUMH:
486 case PPC::VPMSUMW:
487 case PPC::VRLB:
488 case PPC::VRLD:
489 case PPC::VRLH:
490 case PPC::VRLW:
491 case PPC::VSBOX:
492 case PPC::VSHASIGMAD:
493 case PPC::VSHASIGMAW:
494 case PPC::VSL:
495 case PPC::VSLDOI:
496 case PPC::VSLO:
497 case PPC::VSR:
498 case PPC::VSRO:
499 case PPC::VSUM2SWS:
500 case PPC::VSUM4SBS:
501 case PPC::VSUM4SHS:
502 case PPC::VSUM4UBS:
503 case PPC::VSUMSWS:
504 case PPC::VUPKHPX:
505 case PPC::VUPKHSB:
506 case PPC::VUPKHSH:
Bill Schmidt5ed84cd2015-05-16 01:02:12 +0000507 case PPC::VUPKHSW:
Bill Schmidtfe723b92015-04-27 19:57:34 +0000508 case PPC::VUPKLPX:
509 case PPC::VUPKLSB:
510 case PPC::VUPKLSH:
Bill Schmidt5ed84cd2015-05-16 01:02:12 +0000511 case PPC::VUPKLSW:
Bill Schmidtfe723b92015-04-27 19:57:34 +0000512 case PPC::XXMRGHW:
513 case PPC::XXMRGLW:
Bill Schmidt15deb802015-07-13 22:58:19 +0000514 // XXSLDWI could be replaced by a general permute with one of three
515 // permute control vectors (for shift values 1, 2, 3). However,
516 // VPERM has a more restrictive register class.
517 case PPC::XXSLDWI:
Bill Schmidtfe723b92015-04-27 19:57:34 +0000518 break;
519 }
520 }
521 }
522
523 if (RelevantFunction) {
524 DEBUG(dbgs() << "Swap vector when first built\n\n");
525 dumpSwapVector();
526 }
527
528 return RelevantFunction;
529}
530
531// Add an entry to the swap vector and swap map, and make a
532// singleton equivalence class for the entry.
533int PPCVSXSwapRemoval::addSwapEntry(MachineInstr *MI,
534 PPCVSXSwapEntry& SwapEntry) {
535 SwapEntry.VSEMI = MI;
536 SwapEntry.VSEId = SwapVector.size();
537 SwapVector.push_back(SwapEntry);
538 EC->insert(SwapEntry.VSEId);
539 SwapMap[MI] = SwapEntry.VSEId;
540 return SwapEntry.VSEId;
541}
542
543// This is used to find the "true" source register for an
544// XXPERMDI instruction, since MachineCSE does not handle the
545// "copy-like" operations (Copy and SubregToReg). Returns
546// the original SrcReg unless it is the target of a copy-like
547// operation, in which case we chain backwards through all
548// such operations to the ultimate source register. If a
549// physical register is encountered, we stop the search and
550// flag the swap entry indicated by VecIdx (the original
Bill Schmidta1c30052015-07-02 19:01:22 +0000551// XXPERMDI) as mentioning a physical register.
Bill Schmidtfe723b92015-04-27 19:57:34 +0000552unsigned PPCVSXSwapRemoval::lookThruCopyLike(unsigned SrcReg,
553 unsigned VecIdx) {
554 MachineInstr *MI = MRI->getVRegDef(SrcReg);
555 if (!MI->isCopyLike())
556 return SrcReg;
557
Bill Schmidta1c30052015-07-02 19:01:22 +0000558 unsigned CopySrcReg;
559 if (MI->isCopy())
Bill Schmidtfe723b92015-04-27 19:57:34 +0000560 CopySrcReg = MI->getOperand(1).getReg();
Bill Schmidta1c30052015-07-02 19:01:22 +0000561 else {
Bill Schmidtfe723b92015-04-27 19:57:34 +0000562 assert(MI->isSubregToReg() && "bad opcode for lookThruCopyLike");
563 CopySrcReg = MI->getOperand(2).getReg();
Bill Schmidtfe723b92015-04-27 19:57:34 +0000564 }
565
566 if (!TargetRegisterInfo::isVirtualRegister(CopySrcReg)) {
Bill Schmidt2be80542015-07-21 21:40:17 +0000567 if (!isScalarVecReg(CopySrcReg))
568 SwapVector[VecIdx].MentionsPhysVR = 1;
Bill Schmidtfe723b92015-04-27 19:57:34 +0000569 return CopySrcReg;
570 }
571
Bill Schmidtfe723b92015-04-27 19:57:34 +0000572 return lookThruCopyLike(CopySrcReg, VecIdx);
573}
574
575// Generate equivalence classes for related computations (webs) by
576// def-use relationships of virtual registers. Mention of a physical
577// register terminates the generation of equivalence classes as this
578// indicates a use of a parameter, definition of a return value, use
579// of a value returned from a call, or definition of a parameter to a
580// call. Computations with physical register mentions are flagged
581// as such so their containing webs will not be optimized.
582void PPCVSXSwapRemoval::formWebs() {
583
584 DEBUG(dbgs() << "\n*** Forming webs for swap removal ***\n\n");
585
586 for (unsigned EntryIdx = 0; EntryIdx < SwapVector.size(); ++EntryIdx) {
587
588 MachineInstr *MI = SwapVector[EntryIdx].VSEMI;
589
590 DEBUG(dbgs() << "\n" << SwapVector[EntryIdx].VSEId << " ");
591 DEBUG(MI->dump());
592
593 // It's sufficient to walk vector uses and join them to their unique
Bill Schmidt15deb802015-07-13 22:58:19 +0000594 // definitions. In addition, check full vector register operands
595 // for physical regs. We exclude partial-vector register operands
596 // because we can handle them if copied to a full vector.
Bill Schmidtfe723b92015-04-27 19:57:34 +0000597 for (const MachineOperand &MO : MI->operands()) {
598 if (!MO.isReg())
599 continue;
600
601 unsigned Reg = MO.getReg();
Bill Schmidt15deb802015-07-13 22:58:19 +0000602 if (!isVecReg(Reg) && !isScalarVecReg(Reg))
Bill Schmidtfe723b92015-04-27 19:57:34 +0000603 continue;
604
605 if (!TargetRegisterInfo::isVirtualRegister(Reg)) {
Bill Schmidt15deb802015-07-13 22:58:19 +0000606 if (!(MI->isCopy() && isScalarVecReg(Reg)))
607 SwapVector[EntryIdx].MentionsPhysVR = 1;
Bill Schmidtfe723b92015-04-27 19:57:34 +0000608 continue;
609 }
610
611 if (!MO.isUse())
612 continue;
613
614 MachineInstr* DefMI = MRI->getVRegDef(Reg);
615 assert(SwapMap.find(DefMI) != SwapMap.end() &&
616 "Inconsistency: def of vector reg not found in swap map!");
617 int DefIdx = SwapMap[DefMI];
618 (void)EC->unionSets(SwapVector[DefIdx].VSEId,
619 SwapVector[EntryIdx].VSEId);
620
621 DEBUG(dbgs() << format("Unioning %d with %d\n", SwapVector[DefIdx].VSEId,
622 SwapVector[EntryIdx].VSEId));
623 DEBUG(dbgs() << " Def: ");
624 DEBUG(DefMI->dump());
625 }
626 }
627}
628
629// Walk the swap vector entries looking for conditions that prevent their
630// containing computations from being optimized. When such conditions are
631// found, mark the representative of the computation's equivalence class
632// as rejected.
633void PPCVSXSwapRemoval::recordUnoptimizableWebs() {
634
635 DEBUG(dbgs() << "\n*** Rejecting webs for swap removal ***\n\n");
636
637 for (unsigned EntryIdx = 0; EntryIdx < SwapVector.size(); ++EntryIdx) {
638 int Repr = EC->getLeaderValue(SwapVector[EntryIdx].VSEId);
639
Bill Schmidt15deb802015-07-13 22:58:19 +0000640 // If representative is already rejected, don't waste further time.
641 if (SwapVector[Repr].WebRejected)
642 continue;
643
644 // Reject webs containing mentions of physical or partial registers, or
645 // containing operations that we don't know how to handle in a lane-
646 // permuted region.
Bill Schmidtfe723b92015-04-27 19:57:34 +0000647 if (SwapVector[EntryIdx].MentionsPhysVR ||
Bill Schmidt15deb802015-07-13 22:58:19 +0000648 SwapVector[EntryIdx].MentionsPartialVR ||
Bill Schmidtfe723b92015-04-27 19:57:34 +0000649 !(SwapVector[EntryIdx].IsSwappable || SwapVector[EntryIdx].IsSwap)) {
650
651 SwapVector[Repr].WebRejected = 1;
652
653 DEBUG(dbgs() <<
Bill Schmidt2be80542015-07-21 21:40:17 +0000654 format("Web %d rejected for physreg, partial reg, or not "
655 "swap[pable]\n", Repr));
Bill Schmidtfe723b92015-04-27 19:57:34 +0000656 DEBUG(dbgs() << " in " << EntryIdx << ": ");
657 DEBUG(SwapVector[EntryIdx].VSEMI->dump());
658 DEBUG(dbgs() << "\n");
659 }
660
661 // Reject webs than contain swapping loads that feed something other
662 // than a swap instruction.
663 else if (SwapVector[EntryIdx].IsLoad && SwapVector[EntryIdx].IsSwap) {
664 MachineInstr *MI = SwapVector[EntryIdx].VSEMI;
665 unsigned DefReg = MI->getOperand(0).getReg();
666
667 // We skip debug instructions in the analysis. (Note that debug
668 // location information is still maintained by this optimization
669 // because it remains on the LXVD2X and STXVD2X instructions after
670 // the XXPERMDIs are removed.)
671 for (MachineInstr &UseMI : MRI->use_nodbg_instructions(DefReg)) {
672 int UseIdx = SwapMap[&UseMI];
673
674 if (!SwapVector[UseIdx].IsSwap || SwapVector[UseIdx].IsLoad ||
675 SwapVector[UseIdx].IsStore) {
676
677 SwapVector[Repr].WebRejected = 1;
678
679 DEBUG(dbgs() <<
680 format("Web %d rejected for load not feeding swap\n", Repr));
681 DEBUG(dbgs() << " def " << EntryIdx << ": ");
682 DEBUG(MI->dump());
683 DEBUG(dbgs() << " use " << UseIdx << ": ");
684 DEBUG(UseMI.dump());
685 DEBUG(dbgs() << "\n");
686 }
687 }
688
Bill Schmidt15deb802015-07-13 22:58:19 +0000689 // Reject webs that contain swapping stores that are fed by something
Bill Schmidtfe723b92015-04-27 19:57:34 +0000690 // other than a swap instruction.
691 } else if (SwapVector[EntryIdx].IsStore && SwapVector[EntryIdx].IsSwap) {
692 MachineInstr *MI = SwapVector[EntryIdx].VSEMI;
693 unsigned UseReg = MI->getOperand(0).getReg();
694 MachineInstr *DefMI = MRI->getVRegDef(UseReg);
695 int DefIdx = SwapMap[DefMI];
696
697 if (!SwapVector[DefIdx].IsSwap || SwapVector[DefIdx].IsLoad ||
698 SwapVector[DefIdx].IsStore) {
699
700 SwapVector[Repr].WebRejected = 1;
701
702 DEBUG(dbgs() <<
703 format("Web %d rejected for store not fed by swap\n", Repr));
704 DEBUG(dbgs() << " def " << DefIdx << ": ");
705 DEBUG(DefMI->dump());
706 DEBUG(dbgs() << " use " << EntryIdx << ": ");
707 DEBUG(MI->dump());
708 DEBUG(dbgs() << "\n");
709 }
710 }
711 }
712
713 DEBUG(dbgs() << "Swap vector after web analysis:\n\n");
714 dumpSwapVector();
715}
716
717// Walk the swap vector entries looking for swaps fed by permuting loads
718// and swaps that feed permuting stores. If the containing computation
719// has not been marked rejected, mark each such swap for removal.
720// (Removal is delayed in case optimization has disturbed the pattern,
721// such that multiple loads feed the same swap, etc.)
722void PPCVSXSwapRemoval::markSwapsForRemoval() {
723
724 DEBUG(dbgs() << "\n*** Marking swaps for removal ***\n\n");
725
726 for (unsigned EntryIdx = 0; EntryIdx < SwapVector.size(); ++EntryIdx) {
727
728 if (SwapVector[EntryIdx].IsLoad && SwapVector[EntryIdx].IsSwap) {
729 int Repr = EC->getLeaderValue(SwapVector[EntryIdx].VSEId);
730
731 if (!SwapVector[Repr].WebRejected) {
732 MachineInstr *MI = SwapVector[EntryIdx].VSEMI;
733 unsigned DefReg = MI->getOperand(0).getReg();
734
735 for (MachineInstr &UseMI : MRI->use_nodbg_instructions(DefReg)) {
736 int UseIdx = SwapMap[&UseMI];
737 SwapVector[UseIdx].WillRemove = 1;
738
739 DEBUG(dbgs() << "Marking swap fed by load for removal: ");
740 DEBUG(UseMI.dump());
741 }
742 }
743
744 } else if (SwapVector[EntryIdx].IsStore && SwapVector[EntryIdx].IsSwap) {
745 int Repr = EC->getLeaderValue(SwapVector[EntryIdx].VSEId);
746
747 if (!SwapVector[Repr].WebRejected) {
748 MachineInstr *MI = SwapVector[EntryIdx].VSEMI;
749 unsigned UseReg = MI->getOperand(0).getReg();
750 MachineInstr *DefMI = MRI->getVRegDef(UseReg);
751 int DefIdx = SwapMap[DefMI];
752 SwapVector[DefIdx].WillRemove = 1;
753
754 DEBUG(dbgs() << "Marking swap feeding store for removal: ");
755 DEBUG(DefMI->dump());
756 }
757
758 } else if (SwapVector[EntryIdx].IsSwappable &&
Bill Schmidt5fe2e252015-05-06 15:40:46 +0000759 SwapVector[EntryIdx].SpecialHandling != 0) {
760 int Repr = EC->getLeaderValue(SwapVector[EntryIdx].VSEId);
761
762 if (!SwapVector[Repr].WebRejected)
763 handleSpecialSwappables(EntryIdx);
764 }
Bill Schmidtfe723b92015-04-27 19:57:34 +0000765 }
766}
767
Bill Schmidt2be80542015-07-21 21:40:17 +0000768// Create an xxswapd instruction and insert it prior to the given point.
769// MI is used to determine basic block and debug loc information.
770// FIXME: When inserting a swap, we should check whether SrcReg is
771// defined by another swap: SrcReg = XXPERMDI Reg, Reg, 2; If so,
772// then instead we should generate a copy from Reg to DstReg.
773void PPCVSXSwapRemoval::insertSwap(MachineInstr *MI,
774 MachineBasicBlock::iterator InsertPoint,
775 unsigned DstReg, unsigned SrcReg) {
776 BuildMI(*MI->getParent(), InsertPoint, MI->getDebugLoc(),
777 TII->get(PPC::XXPERMDI), DstReg)
778 .addReg(SrcReg)
779 .addReg(SrcReg)
780 .addImm(2);
781}
782
Bill Schmidtfe723b92015-04-27 19:57:34 +0000783// The identified swap entry requires special handling to allow its
784// containing computation to be optimized. Perform that handling
785// here.
Bill Schmidt15deb802015-07-13 22:58:19 +0000786// FIXME: Additional opportunities will be phased in with subsequent
787// patches.
Bill Schmidtfe723b92015-04-27 19:57:34 +0000788void PPCVSXSwapRemoval::handleSpecialSwappables(int EntryIdx) {
Bill Schmidt5fe2e252015-05-06 15:40:46 +0000789 switch (SwapVector[EntryIdx].SpecialHandling) {
790
791 default:
Benjamin Kramer8ceb3232015-10-25 22:28:27 +0000792 llvm_unreachable("Unexpected special handling type");
Bill Schmidt5fe2e252015-05-06 15:40:46 +0000793
794 // For splats based on an index into a vector, add N/2 modulo N
795 // to the index, where N is the number of vector elements.
796 case SHValues::SH_SPLAT: {
797 MachineInstr *MI = SwapVector[EntryIdx].VSEMI;
798 unsigned NElts;
799
800 DEBUG(dbgs() << "Changing splat: ");
801 DEBUG(MI->dump());
802
803 switch (MI->getOpcode()) {
804 default:
Benjamin Kramer8ceb3232015-10-25 22:28:27 +0000805 llvm_unreachable("Unexpected splat opcode");
Bill Schmidt5fe2e252015-05-06 15:40:46 +0000806 case PPC::VSPLTB: NElts = 16; break;
807 case PPC::VSPLTH: NElts = 8; break;
Nemanja Ivanovic1a2b2f02016-05-04 16:04:02 +0000808 case PPC::VSPLTW:
809 case PPC::XXSPLTW: NElts = 4; break;
Bill Schmidt5fe2e252015-05-06 15:40:46 +0000810 }
811
Nemanja Ivanovic1a2b2f02016-05-04 16:04:02 +0000812 unsigned EltNo;
813 if (MI->getOpcode() == PPC::XXSPLTW)
814 EltNo = MI->getOperand(2).getImm();
815 else
816 EltNo = MI->getOperand(1).getImm();
817
Bill Schmidt5fe2e252015-05-06 15:40:46 +0000818 EltNo = (EltNo + NElts / 2) % NElts;
Nemanja Ivanovic1a2b2f02016-05-04 16:04:02 +0000819 if (MI->getOpcode() == PPC::XXSPLTW)
820 MI->getOperand(2).setImm(EltNo);
821 else
822 MI->getOperand(1).setImm(EltNo);
Bill Schmidt5fe2e252015-05-06 15:40:46 +0000823
824 DEBUG(dbgs() << " Into: ");
825 DEBUG(MI->dump());
826 break;
827 }
828
Bill Schmidt15deb802015-07-13 22:58:19 +0000829 // For an XXPERMDI that isn't handled otherwise, we need to
830 // reverse the order of the operands. If the selector operand
831 // has a value of 0 or 3, we need to change it to 3 or 0,
832 // respectively. Otherwise we should leave it alone. (This
833 // is equivalent to reversing the two bits of the selector
834 // operand and complementing the result.)
835 case SHValues::SH_XXPERMDI: {
836 MachineInstr *MI = SwapVector[EntryIdx].VSEMI;
837
838 DEBUG(dbgs() << "Changing XXPERMDI: ");
839 DEBUG(MI->dump());
840
841 unsigned Selector = MI->getOperand(3).getImm();
842 if (Selector == 0 || Selector == 3)
843 Selector = 3 - Selector;
844 MI->getOperand(3).setImm(Selector);
845
846 unsigned Reg1 = MI->getOperand(1).getReg();
847 unsigned Reg2 = MI->getOperand(2).getReg();
848 MI->getOperand(1).setReg(Reg2);
849 MI->getOperand(2).setReg(Reg1);
850
851 DEBUG(dbgs() << " Into: ");
852 DEBUG(MI->dump());
853 break;
854 }
855
856 // For a copy from a scalar floating-point register to a vector
857 // register, removing swaps will leave the copied value in the
858 // wrong lane. Insert a swap following the copy to fix this.
Bill Schmidt2be80542015-07-21 21:40:17 +0000859 case SHValues::SH_COPYWIDEN: {
Bill Schmidt15deb802015-07-13 22:58:19 +0000860 MachineInstr *MI = SwapVector[EntryIdx].VSEMI;
861
862 DEBUG(dbgs() << "Changing SUBREG_TO_REG: ");
863 DEBUG(MI->dump());
864
865 unsigned DstReg = MI->getOperand(0).getReg();
866 const TargetRegisterClass *DstRC = MRI->getRegClass(DstReg);
867 unsigned NewVReg = MRI->createVirtualRegister(DstRC);
868
869 MI->getOperand(0).setReg(NewVReg);
870 DEBUG(dbgs() << " Into: ");
871 DEBUG(MI->dump());
872
Duncan P. N. Exon Smitha3da4482015-10-08 22:20:37 +0000873 auto InsertPoint = ++MachineBasicBlock::iterator(MI);
Bill Schmidt15deb802015-07-13 22:58:19 +0000874
875 // Note that an XXPERMDI requires a VSRC, so if the SUBREG_TO_REG
876 // is copying to a VRRC, we need to be careful to avoid a register
877 // assignment problem. In this case we must copy from VRRC to VSRC
878 // prior to the swap, and from VSRC to VRRC following the swap.
879 // Coalescing will usually remove all this mess.
Bill Schmidt15deb802015-07-13 22:58:19 +0000880 if (DstRC == &PPC::VRRCRegClass) {
881 unsigned VSRCTmp1 = MRI->createVirtualRegister(&PPC::VSRCRegClass);
882 unsigned VSRCTmp2 = MRI->createVirtualRegister(&PPC::VSRCRegClass);
883
884 BuildMI(*MI->getParent(), InsertPoint, MI->getDebugLoc(),
885 TII->get(PPC::COPY), VSRCTmp1)
886 .addReg(NewVReg);
Duncan P. N. Exon Smitha3da4482015-10-08 22:20:37 +0000887 DEBUG(std::prev(InsertPoint)->dump());
Bill Schmidt15deb802015-07-13 22:58:19 +0000888
Bill Schmidt2be80542015-07-21 21:40:17 +0000889 insertSwap(MI, InsertPoint, VSRCTmp2, VSRCTmp1);
Duncan P. N. Exon Smitha3da4482015-10-08 22:20:37 +0000890 DEBUG(std::prev(InsertPoint)->dump());
Bill Schmidt15deb802015-07-13 22:58:19 +0000891
892 BuildMI(*MI->getParent(), InsertPoint, MI->getDebugLoc(),
893 TII->get(PPC::COPY), DstReg)
894 .addReg(VSRCTmp2);
Duncan P. N. Exon Smitha3da4482015-10-08 22:20:37 +0000895 DEBUG(std::prev(InsertPoint)->dump());
Bill Schmidt15deb802015-07-13 22:58:19 +0000896
897 } else {
Bill Schmidt2be80542015-07-21 21:40:17 +0000898 insertSwap(MI, InsertPoint, DstReg, NewVReg);
Duncan P. N. Exon Smitha3da4482015-10-08 22:20:37 +0000899 DEBUG(std::prev(InsertPoint)->dump());
Bill Schmidt15deb802015-07-13 22:58:19 +0000900 }
901 break;
902 }
Bill Schmidt5fe2e252015-05-06 15:40:46 +0000903 }
Bill Schmidtfe723b92015-04-27 19:57:34 +0000904}
905
906// Walk the swap vector and replace each entry marked for removal with
907// a copy operation.
908bool PPCVSXSwapRemoval::removeSwaps() {
909
910 DEBUG(dbgs() << "\n*** Removing swaps ***\n\n");
911
912 bool Changed = false;
913
914 for (unsigned EntryIdx = 0; EntryIdx < SwapVector.size(); ++EntryIdx) {
915 if (SwapVector[EntryIdx].WillRemove) {
916 Changed = true;
917 MachineInstr *MI = SwapVector[EntryIdx].VSEMI;
918 MachineBasicBlock *MBB = MI->getParent();
919 BuildMI(*MBB, MI, MI->getDebugLoc(),
920 TII->get(TargetOpcode::COPY), MI->getOperand(0).getReg())
921 .addOperand(MI->getOperand(1));
922
923 DEBUG(dbgs() << format("Replaced %d with copy: ",
924 SwapVector[EntryIdx].VSEId));
925 DEBUG(MI->dump());
926
927 MI->eraseFromParent();
928 }
929 }
930
931 return Changed;
932}
933
934// For debug purposes, dump the contents of the swap vector.
935void PPCVSXSwapRemoval::dumpSwapVector() {
936
937 for (unsigned EntryIdx = 0; EntryIdx < SwapVector.size(); ++EntryIdx) {
938
939 MachineInstr *MI = SwapVector[EntryIdx].VSEMI;
940 int ID = SwapVector[EntryIdx].VSEId;
941
942 DEBUG(dbgs() << format("%6d", ID));
943 DEBUG(dbgs() << format("%6d", EC->getLeaderValue(ID)));
944 DEBUG(dbgs() << format(" BB#%3d", MI->getParent()->getNumber()));
945 DEBUG(dbgs() << format(" %14s ", TII->getName(MI->getOpcode())));
946
947 if (SwapVector[EntryIdx].IsLoad)
948 DEBUG(dbgs() << "load ");
949 if (SwapVector[EntryIdx].IsStore)
950 DEBUG(dbgs() << "store ");
951 if (SwapVector[EntryIdx].IsSwap)
952 DEBUG(dbgs() << "swap ");
953 if (SwapVector[EntryIdx].MentionsPhysVR)
954 DEBUG(dbgs() << "physreg ");
Bill Schmidt15deb802015-07-13 22:58:19 +0000955 if (SwapVector[EntryIdx].MentionsPartialVR)
956 DEBUG(dbgs() << "partialreg ");
Bill Schmidtfe723b92015-04-27 19:57:34 +0000957
958 if (SwapVector[EntryIdx].IsSwappable) {
959 DEBUG(dbgs() << "swappable ");
960 switch(SwapVector[EntryIdx].SpecialHandling) {
961 default:
962 DEBUG(dbgs() << "special:**unknown**");
963 break;
964 case SH_NONE:
965 break;
Bill Schmidtfe723b92015-04-27 19:57:34 +0000966 case SH_EXTRACT:
967 DEBUG(dbgs() << "special:extract ");
968 break;
969 case SH_INSERT:
970 DEBUG(dbgs() << "special:insert ");
971 break;
972 case SH_NOSWAP_LD:
973 DEBUG(dbgs() << "special:load ");
974 break;
975 case SH_NOSWAP_ST:
976 DEBUG(dbgs() << "special:store ");
977 break;
978 case SH_SPLAT:
979 DEBUG(dbgs() << "special:splat ");
980 break;
Bill Schmidt15deb802015-07-13 22:58:19 +0000981 case SH_XXPERMDI:
982 DEBUG(dbgs() << "special:xxpermdi ");
983 break;
Bill Schmidt2be80542015-07-21 21:40:17 +0000984 case SH_COPYWIDEN:
985 DEBUG(dbgs() << "special:copywiden ");
Bill Schmidt15deb802015-07-13 22:58:19 +0000986 break;
Bill Schmidtfe723b92015-04-27 19:57:34 +0000987 }
988 }
989
990 if (SwapVector[EntryIdx].WebRejected)
991 DEBUG(dbgs() << "rejected ");
992 if (SwapVector[EntryIdx].WillRemove)
993 DEBUG(dbgs() << "remove ");
994
995 DEBUG(dbgs() << "\n");
Bill Schmidte71db852015-04-27 20:22:35 +0000996
997 // For no-asserts builds.
998 (void)MI;
999 (void)ID;
Bill Schmidtfe723b92015-04-27 19:57:34 +00001000 }
1001
1002 DEBUG(dbgs() << "\n");
1003}
1004
Alexander Kornienkof00654e2015-06-23 09:49:53 +00001005} // end default namespace
Bill Schmidtfe723b92015-04-27 19:57:34 +00001006
1007INITIALIZE_PASS_BEGIN(PPCVSXSwapRemoval, DEBUG_TYPE,
1008 "PowerPC VSX Swap Removal", false, false)
1009INITIALIZE_PASS_END(PPCVSXSwapRemoval, DEBUG_TYPE,
1010 "PowerPC VSX Swap Removal", false, false)
1011
1012char PPCVSXSwapRemoval::ID = 0;
1013FunctionPass*
1014llvm::createPPCVSXSwapRemovalPass() { return new PPCVSXSwapRemoval(); }