blob: 901753713f610e8e3fcd5626b968fa6866f762f1 [file] [log] [blame]
Sjoerd Meijerc89ca552018-06-28 12:55:29 +00001//===- ParallelDSP.cpp - Parallel DSP Pass --------------------------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Sjoerd Meijerc89ca552018-06-28 12:55:29 +00006//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// Armv6 introduced instructions to perform 32-bit SIMD operations. The
11/// purpose of this pass is do some IR pattern matching to create ACLE
12/// DSP intrinsics, which map on these 32-bit SIMD operations.
Sjoerd Meijer53449da2018-07-11 12:36:25 +000013/// This pass runs only when unaligned accesses is supported/enabled.
Sjoerd Meijerc89ca552018-06-28 12:55:29 +000014//
15//===----------------------------------------------------------------------===//
16
Sjoerd Meijerb3e06fa2018-07-06 14:47:09 +000017#include "llvm/ADT/Statistic.h"
Sjoerd Meijerc89ca552018-06-28 12:55:29 +000018#include "llvm/ADT/SmallPtrSet.h"
19#include "llvm/Analysis/AliasAnalysis.h"
20#include "llvm/Analysis/LoopAccessAnalysis.h"
21#include "llvm/Analysis/LoopPass.h"
22#include "llvm/Analysis/LoopInfo.h"
23#include "llvm/IR/Instructions.h"
24#include "llvm/IR/NoFolder.h"
25#include "llvm/Transforms/Scalar.h"
26#include "llvm/Transforms/Utils/BasicBlockUtils.h"
27#include "llvm/Transforms/Utils/LoopUtils.h"
28#include "llvm/Pass.h"
29#include "llvm/PassRegistry.h"
30#include "llvm/PassSupport.h"
31#include "llvm/Support/Debug.h"
32#include "llvm/IR/PatternMatch.h"
33#include "llvm/CodeGen/TargetPassConfig.h"
34#include "ARM.h"
35#include "ARMSubtarget.h"
36
37using namespace llvm;
38using namespace PatternMatch;
39
Sjoerd Meijerb3e06fa2018-07-06 14:47:09 +000040#define DEBUG_TYPE "arm-parallel-dsp"
41
42STATISTIC(NumSMLAD , "Number of smlad instructions generated");
Sjoerd Meijerc89ca552018-06-28 12:55:29 +000043
Sjoerd Meijer3c859b32018-08-14 07:43:49 +000044static cl::opt<bool>
45DisableParallelDSP("disable-arm-parallel-dsp", cl::Hidden, cl::init(false),
46 cl::desc("Disable the ARM Parallel DSP pass"));
47
Sjoerd Meijerc89ca552018-06-28 12:55:29 +000048namespace {
Sam Parker89a37992018-07-23 15:25:59 +000049 struct OpChain;
50 struct BinOpChain;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +000051 struct Reduction;
52
Fangrui Song58407ca2018-07-23 17:43:21 +000053 using OpChainList = SmallVector<std::unique_ptr<OpChain>, 8>;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +000054 using ReductionList = SmallVector<Reduction, 8>;
55 using ValueList = SmallVector<Value*, 8>;
Sam Parker4c4ff132019-03-14 11:14:13 +000056 using MemInstList = SmallVector<LoadInst*, 8>;
Sam Parker89a37992018-07-23 15:25:59 +000057 using PMACPair = std::pair<BinOpChain*,BinOpChain*>;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +000058 using PMACPairList = SmallVector<PMACPair, 8>;
59 using Instructions = SmallVector<Instruction*,16>;
60 using MemLocList = SmallVector<MemoryLocation, 4>;
61
Sam Parker89a37992018-07-23 15:25:59 +000062 struct OpChain {
63 Instruction *Root;
64 ValueList AllValues;
Eli Friedmanb09c7782018-10-18 19:34:30 +000065 MemInstList VecLd; // List of all load instructions.
Sam Parker89a37992018-07-23 15:25:59 +000066 MemLocList MemLocs; // All memory locations read by this tree.
67 bool ReadOnly = true;
68
69 OpChain(Instruction *I, ValueList &vl) : Root(I), AllValues(vl) { }
Jordan Rupprechte5daf612018-07-23 17:38:05 +000070 virtual ~OpChain() = default;
Sam Parker89a37992018-07-23 15:25:59 +000071
72 void SetMemoryLocations() {
George Burgess IV6ef80022018-10-10 21:28:44 +000073 const auto Size = LocationSize::unknown();
Sam Parker89a37992018-07-23 15:25:59 +000074 for (auto *V : AllValues) {
75 if (auto *I = dyn_cast<Instruction>(V)) {
76 if (I->mayWriteToMemory())
77 ReadOnly = false;
Eli Friedmanb09c7782018-10-18 19:34:30 +000078 if (auto *Ld = dyn_cast<LoadInst>(V))
Sam Parker89a37992018-07-23 15:25:59 +000079 MemLocs.push_back(MemoryLocation(Ld->getPointerOperand(), Size));
80 }
81 }
82 }
83
84 unsigned size() const { return AllValues.size(); }
85 };
86
87 // 'BinOpChain' and 'Reduction' are just some bookkeeping data structures.
Sjoerd Meijerc89ca552018-06-28 12:55:29 +000088 // 'Reduction' contains the phi-node and accumulator statement from where we
Sam Parker89a37992018-07-23 15:25:59 +000089 // start pattern matching, and 'BinOpChain' the multiplication
Sjoerd Meijerc89ca552018-06-28 12:55:29 +000090 // instructions that are candidates for parallel execution.
Sam Parker89a37992018-07-23 15:25:59 +000091 struct BinOpChain : public OpChain {
92 ValueList LHS; // List of all (narrow) left hand operands.
93 ValueList RHS; // List of all (narrow) right hand operands.
Sam Parkera023c7a2018-09-12 09:17:44 +000094 bool Exchange = false;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +000095
Sam Parker89a37992018-07-23 15:25:59 +000096 BinOpChain(Instruction *I, ValueList &lhs, ValueList &rhs) :
97 OpChain(I, lhs), LHS(lhs), RHS(rhs) {
98 for (auto *V : RHS)
99 AllValues.push_back(V);
100 }
Sam Parker453ba912018-11-09 09:18:00 +0000101
102 bool AreSymmetrical(BinOpChain *Other);
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000103 };
104
105 struct Reduction {
106 PHINode *Phi; // The Phi-node from where we start
107 // pattern matching.
108 Instruction *AccIntAdd; // The accumulating integer add statement,
109 // i.e, the reduction statement.
Sam Parker89a37992018-07-23 15:25:59 +0000110 OpChainList MACCandidates; // The MAC candidates associated with
Sjoerd Meijer53449da2018-07-11 12:36:25 +0000111 // this reduction statement.
Sam Parker453ba912018-11-09 09:18:00 +0000112 PMACPairList PMACPairs;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000113 Reduction (PHINode *P, Instruction *Acc) : Phi(P), AccIntAdd(Acc) { };
114 };
115
Sam Parker4c4ff132019-03-14 11:14:13 +0000116 class WidenedLoad {
117 LoadInst *NewLd = nullptr;
118 SmallVector<LoadInst*, 4> Loads;
119
120 public:
121 WidenedLoad(SmallVectorImpl<LoadInst*> &Lds, LoadInst *Wide)
122 : NewLd(Wide) {
123 for (auto *I : Lds)
124 Loads.push_back(I);
125 }
126 LoadInst *getLoad() {
127 return NewLd;
128 }
129 };
130
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000131 class ARMParallelDSP : public LoopPass {
132 ScalarEvolution *SE;
133 AliasAnalysis *AA;
134 TargetLibraryInfo *TLI;
135 DominatorTree *DT;
136 LoopInfo *LI;
137 Loop *L;
138 const DataLayout *DL;
139 Module *M;
Sam Parker453ba912018-11-09 09:18:00 +0000140 std::map<LoadInst*, LoadInst*> LoadPairs;
Sam Parker4c4ff132019-03-14 11:14:13 +0000141 std::map<LoadInst*, std::unique_ptr<WidenedLoad>> WideLoads;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000142
Sam Parker4c4ff132019-03-14 11:14:13 +0000143 bool RecordSequentialLoads(BasicBlock *BB);
Sam Parker453ba912018-11-09 09:18:00 +0000144 bool InsertParallelMACs(Reduction &Reduction);
Fangrui Song68169342018-07-03 19:12:27 +0000145 bool AreSequentialLoads(LoadInst *Ld0, LoadInst *Ld1, MemInstList &VecMem);
Sam Parker4c4ff132019-03-14 11:14:13 +0000146 LoadInst* CreateLoadIns(IRBuilder<NoFolder> &IRB,
147 SmallVectorImpl<LoadInst*> &Loads,
148 IntegerType *LoadTy);
Sam Parker453ba912018-11-09 09:18:00 +0000149 void CreateParallelMACPairs(Reduction &R);
Sam Parker4c4ff132019-03-14 11:14:13 +0000150 Instruction *CreateSMLADCall(SmallVectorImpl<LoadInst*> &VecLd0,
151 SmallVectorImpl<LoadInst*> &VecLd1,
Sam Parkera023c7a2018-09-12 09:17:44 +0000152 Instruction *Acc, bool Exchange,
153 Instruction *InsertAfter);
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000154
155 /// Try to match and generate: SMLAD, SMLADX - Signed Multiply Accumulate
156 /// Dual performs two signed 16x16-bit multiplications. It adds the
157 /// products to a 32-bit accumulate operand. Optionally, the instruction can
158 /// exchange the halfwords of the second operand before performing the
159 /// arithmetic.
160 bool MatchSMLAD(Function &F);
161
162 public:
163 static char ID;
164
165 ARMParallelDSP() : LoopPass(ID) { }
166
167 void getAnalysisUsage(AnalysisUsage &AU) const override {
168 LoopPass::getAnalysisUsage(AU);
169 AU.addRequired<AssumptionCacheTracker>();
170 AU.addRequired<ScalarEvolutionWrapperPass>();
171 AU.addRequired<AAResultsWrapperPass>();
172 AU.addRequired<TargetLibraryInfoWrapperPass>();
173 AU.addRequired<LoopInfoWrapperPass>();
174 AU.addRequired<DominatorTreeWrapperPass>();
175 AU.addRequired<TargetPassConfig>();
176 AU.addPreserved<LoopInfoWrapperPass>();
177 AU.setPreservesCFG();
178 }
179
180 bool runOnLoop(Loop *TheLoop, LPPassManager &) override {
Sjoerd Meijer3c859b32018-08-14 07:43:49 +0000181 if (DisableParallelDSP)
182 return false;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000183 L = TheLoop;
184 SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
185 AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
186 TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
187 DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
188 LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
189 auto &TPC = getAnalysis<TargetPassConfig>();
190
191 BasicBlock *Header = TheLoop->getHeader();
192 if (!Header)
193 return false;
194
195 // TODO: We assume the loop header and latch to be the same block.
196 // This is not a fundamental restriction, but lifting this would just
197 // require more work to do the transformation and then patch up the CFG.
198 if (Header != TheLoop->getLoopLatch()) {
199 LLVM_DEBUG(dbgs() << "The loop header is not the loop latch: not "
200 "running pass ARMParallelDSP\n");
201 return false;
202 }
203
Sam Parker9e730202019-03-15 10:19:32 +0000204 // We need a preheader as getIncomingValueForBlock assumes there is one.
205 if (!TheLoop->getLoopPreheader()) {
206 LLVM_DEBUG(dbgs() << "No preheader found, bailing out\n");
207 return false;
208 }
209
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000210 Function &F = *Header->getParent();
211 M = F.getParent();
212 DL = &M->getDataLayout();
213
214 auto &TM = TPC.getTM<TargetMachine>();
215 auto *ST = &TM.getSubtarget<ARMSubtarget>(F);
216
217 if (!ST->allowsUnalignedMem()) {
218 LLVM_DEBUG(dbgs() << "Unaligned memory access not supported: not "
219 "running pass ARMParallelDSP\n");
220 return false;
221 }
222
223 if (!ST->hasDSP()) {
224 LLVM_DEBUG(dbgs() << "DSP extension not enabled: not running pass "
225 "ARMParallelDSP\n");
226 return false;
227 }
228
Sam Parker9e730202019-03-15 10:19:32 +0000229 if (!ST->isLittle()) {
230 LLVM_DEBUG(dbgs() << "Only supporting little endian: not running pass "
231 "ARMParallelDSP\n");
232 return false;
233 }
234
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000235 LoopAccessInfo LAI(L, SE, TLI, AA, DT, LI);
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000236
Sam Parkera023c7a2018-09-12 09:17:44 +0000237 LLVM_DEBUG(dbgs() << "\n== Parallel DSP pass ==\n");
238 LLVM_DEBUG(dbgs() << " - " << F.getName() << "\n\n");
Sam Parker453ba912018-11-09 09:18:00 +0000239
240 if (!RecordSequentialLoads(Header)) {
241 LLVM_DEBUG(dbgs() << " - No sequential loads found.\n");
242 return false;
243 }
244
Sam Parker4c4ff132019-03-14 11:14:13 +0000245 bool Changes = MatchSMLAD(F);
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000246 return Changes;
247 }
248 };
249}
250
Sjoerd Meijer27be58b2018-07-05 08:21:40 +0000251// MaxBitwidth: the maximum supported bitwidth of the elements in the DSP
252// instructions, which is set to 16. So here we should collect all i8 and i16
253// narrow operations.
254// TODO: we currently only collect i16, and will support i8 later, so that's
255// why we check that types are equal to MaxBitWidth, and not <= MaxBitWidth.
256template<unsigned MaxBitWidth>
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000257static bool IsNarrowSequence(Value *V, ValueList &VL) {
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000258 ConstantInt *CInt;
259
260 if (match(V, m_ConstantInt(CInt))) {
261 // TODO: if a constant is used, it needs to fit within the bit width.
262 return false;
263 }
264
265 auto *I = dyn_cast<Instruction>(V);
266 if (!I)
267 return false;
268
269 Value *Val, *LHS, *RHS;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000270 if (match(V, m_Trunc(m_Value(Val)))) {
Sjoerd Meijer27be58b2018-07-05 08:21:40 +0000271 if (cast<TruncInst>(I)->getDestTy()->getIntegerBitWidth() == MaxBitWidth)
272 return IsNarrowSequence<MaxBitWidth>(Val, VL);
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000273 } else if (match(V, m_Add(m_Value(LHS), m_Value(RHS)))) {
274 // TODO: we need to implement sadd16/sadd8 for this, which enables to
275 // also do the rewrite for smlad8.ll, but it is unsupported for now.
Sjoerd Meijer27be58b2018-07-05 08:21:40 +0000276 return false;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000277 } else if (match(V, m_ZExtOrSExt(m_Value(Val)))) {
Sam Parker4c4ff132019-03-14 11:14:13 +0000278 if (cast<CastInst>(I)->getSrcTy()->getIntegerBitWidth() != MaxBitWidth)
Sjoerd Meijer27be58b2018-07-05 08:21:40 +0000279 return false;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000280
Sjoerd Meijer27be58b2018-07-05 08:21:40 +0000281 if (match(Val, m_Load(m_Value()))) {
Sjoerd Meijer27be58b2018-07-05 08:21:40 +0000282 VL.push_back(Val);
283 VL.push_back(I);
284 return true;
285 }
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000286 }
Sjoerd Meijer27be58b2018-07-05 08:21:40 +0000287 return false;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000288}
289
Sam Parkerffc16812018-07-03 12:44:16 +0000290template<typename MemInst>
291static bool AreSequentialAccesses(MemInst *MemOp0, MemInst *MemOp1,
Sam Parker453ba912018-11-09 09:18:00 +0000292 const DataLayout &DL, ScalarEvolution &SE) {
Sam Parker4c4ff132019-03-14 11:14:13 +0000293 if (isConsecutiveAccess(MemOp0, MemOp1, DL, SE))
Sam Parkerffc16812018-07-03 12:44:16 +0000294 return true;
Sam Parkerffc16812018-07-03 12:44:16 +0000295 return false;
296}
297
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000298bool ARMParallelDSP::AreSequentialLoads(LoadInst *Ld0, LoadInst *Ld1,
Sam Parkerffc16812018-07-03 12:44:16 +0000299 MemInstList &VecMem) {
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000300 if (!Ld0 || !Ld1)
301 return false;
302
Sam Parker4c4ff132019-03-14 11:14:13 +0000303 if (!LoadPairs.count(Ld0) || LoadPairs[Ld0] != Ld1)
304 return false;
305
306 LLVM_DEBUG(dbgs() << "Loads are sequential and valid:\n";
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000307 dbgs() << "Ld0:"; Ld0->dump();
308 dbgs() << "Ld1:"; Ld1->dump();
309 );
310
Sam Parker453ba912018-11-09 09:18:00 +0000311 VecMem.clear();
312 VecMem.push_back(Ld0);
313 VecMem.push_back(Ld1);
314 return true;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000315}
316
Sam Parker453ba912018-11-09 09:18:00 +0000317/// Iterate through the block and record base, offset pairs of loads as well as
318/// maximal sequences of sequential loads.
Sam Parker4c4ff132019-03-14 11:14:13 +0000319bool ARMParallelDSP::RecordSequentialLoads(BasicBlock *BB) {
Sam Parker453ba912018-11-09 09:18:00 +0000320 SmallVector<LoadInst*, 8> Loads;
Sam Parker4c4ff132019-03-14 11:14:13 +0000321 for (auto &I : *BB) {
Sam Parker453ba912018-11-09 09:18:00 +0000322 auto *Ld = dyn_cast<LoadInst>(&I);
Sam Parker4c4ff132019-03-14 11:14:13 +0000323 if (!Ld || !Ld->isSimple() ||
324 !Ld->hasOneUse() || !isa<SExtInst>(Ld->user_back()))
Sam Parker453ba912018-11-09 09:18:00 +0000325 continue;
326 Loads.push_back(Ld);
327 }
328
Sam Parker453ba912018-11-09 09:18:00 +0000329 for (auto *Ld0 : Loads) {
330 for (auto *Ld1 : Loads) {
331 if (Ld0 == Ld1)
332 continue;
333
334 if (AreSequentialAccesses<LoadInst>(Ld0, Ld1, *DL, *SE)) {
335 LoadPairs[Ld0] = Ld1;
Sam Parker4c4ff132019-03-14 11:14:13 +0000336 break;
Sam Parker453ba912018-11-09 09:18:00 +0000337 }
338 }
339 }
Sam Parker4c4ff132019-03-14 11:14:13 +0000340
341 LLVM_DEBUG(if (!LoadPairs.empty()) {
342 dbgs() << "Consecutive load pairs:\n";
343 for (auto &MapIt : LoadPairs) {
344 LLVM_DEBUG(dbgs() << *MapIt.first << ", "
345 << *MapIt.second << "\n");
346 }
347 });
Sam Parker453ba912018-11-09 09:18:00 +0000348 return LoadPairs.size() > 1;
349}
350
351void ARMParallelDSP::CreateParallelMACPairs(Reduction &R) {
352 OpChainList &Candidates = R.MACCandidates;
353 PMACPairList &PMACPairs = R.PMACPairs;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000354 const unsigned Elems = Candidates.size();
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000355
356 if (Elems < 2)
Sam Parker453ba912018-11-09 09:18:00 +0000357 return;
358
359 auto CanPair = [&](BinOpChain *PMul0, BinOpChain *PMul1) {
360 if (!PMul0->AreSymmetrical(PMul1))
361 return false;
362
363 // The first elements of each vector should be loads with sexts. If we
364 // find that its two pairs of consecutive loads, then these can be
365 // transformed into two wider loads and the users can be replaced with
366 // DSP intrinsics.
367 for (unsigned x = 0; x < PMul0->LHS.size(); x += 2) {
368 auto *Ld0 = dyn_cast<LoadInst>(PMul0->LHS[x]);
369 auto *Ld1 = dyn_cast<LoadInst>(PMul1->LHS[x]);
370 auto *Ld2 = dyn_cast<LoadInst>(PMul0->RHS[x]);
371 auto *Ld3 = dyn_cast<LoadInst>(PMul1->RHS[x]);
372
373 if (!Ld0 || !Ld1 || !Ld2 || !Ld3)
374 return false;
375
Sam Parker4c4ff132019-03-14 11:14:13 +0000376 LLVM_DEBUG(dbgs() << "Loads:\n"
377 << " - " << *Ld0 << "\n"
378 << " - " << *Ld1 << "\n"
379 << " - " << *Ld2 << "\n"
380 << " - " << *Ld3 << "\n");
Sam Parker453ba912018-11-09 09:18:00 +0000381
382 if (AreSequentialLoads(Ld0, Ld1, PMul0->VecLd)) {
383 if (AreSequentialLoads(Ld2, Ld3, PMul1->VecLd)) {
384 LLVM_DEBUG(dbgs() << "OK: found two pairs of parallel loads!\n");
385 PMACPairs.push_back(std::make_pair(PMul0, PMul1));
386 return true;
387 } else if (AreSequentialLoads(Ld3, Ld2, PMul1->VecLd)) {
388 LLVM_DEBUG(dbgs() << "OK: found two pairs of parallel loads!\n");
389 LLVM_DEBUG(dbgs() << " exchanging Ld2 and Ld3\n");
390 PMul1->Exchange = true;
391 PMACPairs.push_back(std::make_pair(PMul0, PMul1));
392 return true;
393 }
394 } else if (AreSequentialLoads(Ld1, Ld0, PMul0->VecLd) &&
395 AreSequentialLoads(Ld2, Ld3, PMul1->VecLd)) {
396 LLVM_DEBUG(dbgs() << "OK: found two pairs of parallel loads!\n");
397 LLVM_DEBUG(dbgs() << " exchanging Ld0 and Ld1\n");
398 LLVM_DEBUG(dbgs() << " and swapping muls\n");
399 PMul0->Exchange = true;
400 // Only the second operand can be exchanged, so swap the muls.
401 PMACPairs.push_back(std::make_pair(PMul1, PMul0));
402 return true;
403 }
404 }
405 return false;
406 };
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000407
Sam Parkera023c7a2018-09-12 09:17:44 +0000408 SmallPtrSet<const Instruction*, 4> Paired;
409 for (unsigned i = 0; i < Elems; ++i) {
Fangrui Song58407ca2018-07-23 17:43:21 +0000410 BinOpChain *PMul0 = static_cast<BinOpChain*>(Candidates[i].get());
Sam Parkera023c7a2018-09-12 09:17:44 +0000411 if (Paired.count(PMul0->Root))
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000412 continue;
413
Sam Parkera023c7a2018-09-12 09:17:44 +0000414 for (unsigned j = 0; j < Elems; ++j) {
415 if (i == j)
416 continue;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000417
Sam Parkera023c7a2018-09-12 09:17:44 +0000418 BinOpChain *PMul1 = static_cast<BinOpChain*>(Candidates[j].get());
419 if (Paired.count(PMul1->Root))
420 continue;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000421
Sam Parkera023c7a2018-09-12 09:17:44 +0000422 const Instruction *Mul0 = PMul0->Root;
423 const Instruction *Mul1 = PMul1->Root;
424 if (Mul0 == Mul1)
425 continue;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000426
Sam Parkera023c7a2018-09-12 09:17:44 +0000427 assert(PMul0 != PMul1 && "expected different chains");
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000428
Sam Parker453ba912018-11-09 09:18:00 +0000429 if (CanPair(PMul0, PMul1)) {
Sam Parkera023c7a2018-09-12 09:17:44 +0000430 Paired.insert(Mul0);
431 Paired.insert(Mul1);
432 break;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000433 }
434 }
435 }
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000436}
437
Sam Parker453ba912018-11-09 09:18:00 +0000438bool ARMParallelDSP::InsertParallelMACs(Reduction &Reduction) {
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000439 Instruction *Acc = Reduction.Phi;
440 Instruction *InsertAfter = Reduction.AccIntAdd;
441
Sam Parker453ba912018-11-09 09:18:00 +0000442 for (auto &Pair : Reduction.PMACPairs) {
Sam Parkera023c7a2018-09-12 09:17:44 +0000443 BinOpChain *PMul0 = Pair.first;
444 BinOpChain *PMul1 = Pair.second;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000445 LLVM_DEBUG(dbgs() << "Found parallel MACs!!\n";
Sam Parkera023c7a2018-09-12 09:17:44 +0000446 dbgs() << "- "; PMul0->Root->dump();
447 dbgs() << "- "; PMul1->Root->dump());
448
Sam Parker4c4ff132019-03-14 11:14:13 +0000449 Acc = CreateSMLADCall(PMul0->VecLd, PMul1->VecLd, Acc, PMul1->Exchange,
450 InsertAfter);
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000451 InsertAfter = Acc;
452 }
453
454 if (Acc != Reduction.Phi) {
455 LLVM_DEBUG(dbgs() << "Replace Accumulate: "; Acc->dump());
456 Reduction.AccIntAdd->replaceAllUsesWith(Acc);
457 return true;
458 }
459 return false;
460}
461
Sam Parker89a37992018-07-23 15:25:59 +0000462static void MatchReductions(Function &F, Loop *TheLoop, BasicBlock *Header,
463 ReductionList &Reductions) {
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000464 RecurrenceDescriptor RecDesc;
465 const bool HasFnNoNaNAttr =
466 F.getFnAttribute("no-nans-fp-math").getValueAsString() == "true";
467 const BasicBlock *Latch = TheLoop->getLoopLatch();
468
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000469 for (PHINode &Phi : Header->phis()) {
470 const auto *Ty = Phi.getType();
Sam Parker01db2982018-09-11 14:01:22 +0000471 if (!Ty->isIntegerTy(32) && !Ty->isIntegerTy(64))
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000472 continue;
473
474 const bool IsReduction =
475 RecurrenceDescriptor::AddReductionVar(&Phi,
476 RecurrenceDescriptor::RK_IntegerAdd,
477 TheLoop, HasFnNoNaNAttr, RecDesc);
478 if (!IsReduction)
479 continue;
480
481 Instruction *Acc = dyn_cast<Instruction>(Phi.getIncomingValueForBlock(Latch));
482 if (!Acc)
483 continue;
484
485 Reductions.push_back(Reduction(&Phi, Acc));
486 }
487
488 LLVM_DEBUG(
489 dbgs() << "\nAccumulating integer additions (reductions) found:\n";
Sam Parker89a37992018-07-23 15:25:59 +0000490 for (auto &R : Reductions) {
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000491 dbgs() << "- "; R.Phi->dump();
492 dbgs() << "-> "; R.AccIntAdd->dump();
493 }
494 );
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000495}
496
Eli Friedmanb09c7782018-10-18 19:34:30 +0000497static void AddMACCandidate(OpChainList &Candidates,
Sam Parker01db2982018-09-11 14:01:22 +0000498 Instruction *Mul,
499 Value *MulOp0, Value *MulOp1) {
Sam Parker01db2982018-09-11 14:01:22 +0000500 assert(Mul->getOpcode() == Instruction::Mul &&
501 "expected mul instruction");
Sam Parker89a37992018-07-23 15:25:59 +0000502 ValueList LHS;
503 ValueList RHS;
504 if (IsNarrowSequence<16>(MulOp0, LHS) &&
505 IsNarrowSequence<16>(MulOp1, RHS)) {
Fangrui Song58407ca2018-07-23 17:43:21 +0000506 Candidates.push_back(make_unique<BinOpChain>(Mul, LHS, RHS));
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000507 }
508}
509
Sam Parker89a37992018-07-23 15:25:59 +0000510static void MatchParallelMACSequences(Reduction &R,
511 OpChainList &Candidates) {
Sam Parkera023c7a2018-09-12 09:17:44 +0000512 Instruction *Acc = R.AccIntAdd;
Sam Parker4c4ff132019-03-14 11:14:13 +0000513 LLVM_DEBUG(dbgs() << "\n- Analysing:\t" << *Acc << "\n");
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000514
Sam Parkera023c7a2018-09-12 09:17:44 +0000515 // Returns false to signal the search should be stopped.
516 std::function<bool(Value*)> Match =
517 [&Candidates, &Match](Value *V) -> bool {
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000518
Sam Parkera023c7a2018-09-12 09:17:44 +0000519 auto *I = dyn_cast<Instruction>(V);
Sam Parker11879112018-09-12 09:58:56 +0000520 if (!I)
Sam Parkera023c7a2018-09-12 09:17:44 +0000521 return false;
Sam Parker01db2982018-09-11 14:01:22 +0000522
Sam Parkera023c7a2018-09-12 09:17:44 +0000523 switch (I->getOpcode()) {
524 case Instruction::Add:
525 if (Match(I->getOperand(0)) || (Match(I->getOperand(1))))
526 return true;
527 break;
Sam Parker5338f7a2018-11-26 10:22:55 +0000528 case Instruction::Mul: {
529 Value *MulOp0 = I->getOperand(0);
530 Value *MulOp1 = I->getOperand(1);
531 if (isa<SExtInst>(MulOp0) && isa<SExtInst>(MulOp1))
Eli Friedmanb09c7782018-10-18 19:34:30 +0000532 AddMACCandidate(Candidates, I, MulOp0, MulOp1);
Sam Parker5338f7a2018-11-26 10:22:55 +0000533 return false;
534 }
Sam Parkera023c7a2018-09-12 09:17:44 +0000535 case Instruction::SExt:
Sam Parker5338f7a2018-11-26 10:22:55 +0000536 return Match(I->getOperand(0));
Sam Parkera023c7a2018-09-12 09:17:44 +0000537 }
538 return false;
539 };
540
541 while (Match (Acc));
542 LLVM_DEBUG(dbgs() << "Finished matching MAC sequences, found "
543 << Candidates.size() << " candidates.\n");
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000544}
545
546// Collects all instructions that are not part of the MAC chains, which is the
547// set of instructions that can potentially alias with the MAC operands.
Sjoerd Meijer53449da2018-07-11 12:36:25 +0000548static void AliasCandidates(BasicBlock *Header, Instructions &Reads,
549 Instructions &Writes) {
550 for (auto &I : *Header) {
551 if (I.mayReadFromMemory())
552 Reads.push_back(&I);
553 if (I.mayWriteToMemory())
554 Writes.push_back(&I);
555 }
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000556}
557
Sjoerd Meijer53449da2018-07-11 12:36:25 +0000558// Check whether statements in the basic block that write to memory alias with
559// the memory locations accessed by the MAC-chains.
560// TODO: we need the read statements when we accept more complicated chains.
561static bool AreAliased(AliasAnalysis *AA, Instructions &Reads,
Eli Friedmanb09c7782018-10-18 19:34:30 +0000562 Instructions &Writes, OpChainList &MACCandidates) {
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000563 LLVM_DEBUG(dbgs() << "Alias checks:\n");
Eli Friedmanb09c7782018-10-18 19:34:30 +0000564 for (auto &MAC : MACCandidates) {
565 LLVM_DEBUG(dbgs() << "mul: "; MAC->Root->dump());
Sjoerd Meijer53449da2018-07-11 12:36:25 +0000566
567 // At the moment, we allow only simple chains that only consist of reads,
568 // accumulate their result with an integer add, and thus that don't write
569 // memory, and simply bail if they do.
Eli Friedmanb09c7782018-10-18 19:34:30 +0000570 if (!MAC->ReadOnly)
Sjoerd Meijer53449da2018-07-11 12:36:25 +0000571 return true;
572
573 // Now for all writes in the basic block, check that they don't alias with
574 // the memory locations accessed by our MAC-chain:
575 for (auto *I : Writes) {
576 LLVM_DEBUG(dbgs() << "- "; I->dump());
Eli Friedmanb09c7782018-10-18 19:34:30 +0000577 assert(MAC->MemLocs.size() >= 2 && "expecting at least 2 memlocs");
578 for (auto &MemLoc : MAC->MemLocs) {
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000579 if (isModOrRefSet(intersectModRef(AA->getModRefInfo(I, MemLoc),
580 ModRefInfo::ModRef))) {
581 LLVM_DEBUG(dbgs() << "Yes, aliases found\n");
582 return true;
583 }
584 }
585 }
586 }
Sjoerd Meijer53449da2018-07-11 12:36:25 +0000587
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000588 LLVM_DEBUG(dbgs() << "OK: no aliases found!\n");
589 return false;
590}
591
Eli Friedmanb09c7782018-10-18 19:34:30 +0000592static bool CheckMACMemory(OpChainList &Candidates) {
Fangrui Song58407ca2018-07-23 17:43:21 +0000593 for (auto &C : Candidates) {
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000594 // A mul has 2 operands, and a narrow op consist of sext and a load; thus
595 // we expect at least 4 items in this operand value list.
Sam Parker89a37992018-07-23 15:25:59 +0000596 if (C->size() < 4) {
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000597 LLVM_DEBUG(dbgs() << "Operand list too short.\n");
598 return false;
599 }
Eli Friedmanb09c7782018-10-18 19:34:30 +0000600 C->SetMemoryLocations();
Fangrui Song58407ca2018-07-23 17:43:21 +0000601 ValueList &LHS = static_cast<BinOpChain*>(C.get())->LHS;
602 ValueList &RHS = static_cast<BinOpChain*>(C.get())->RHS;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000603
Sam Parker89a37992018-07-23 15:25:59 +0000604 // Use +=2 to skip over the expected extend instructions.
605 for (unsigned i = 0, e = LHS.size(); i < e; i += 2) {
606 if (!isa<LoadInst>(LHS[i]) || !isa<LoadInst>(RHS[i]))
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000607 return false;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000608 }
609 }
610 return true;
611}
612
613// Loop Pass that needs to identify integer add/sub reductions of 16-bit vector
614// multiplications.
615// To use SMLAD:
616// 1) we first need to find integer add reduction PHIs,
617// 2) then from the PHI, look for this pattern:
618//
619// acc0 = phi i32 [0, %entry], [%acc1, %loop.body]
620// ld0 = load i16
621// sext0 = sext i16 %ld0 to i32
622// ld1 = load i16
623// sext1 = sext i16 %ld1 to i32
624// mul0 = mul %sext0, %sext1
625// ld2 = load i16
626// sext2 = sext i16 %ld2 to i32
627// ld3 = load i16
628// sext3 = sext i16 %ld3 to i32
629// mul1 = mul i32 %sext2, %sext3
630// add0 = add i32 %mul0, %acc0
631// acc1 = add i32 %add0, %mul1
632//
633// Which can be selected to:
634//
635// ldr.h r0
636// ldr.h r1
637// smlad r2, r0, r1, r2
638//
639// If constants are used instead of loads, these will need to be hoisted
640// out and into a register.
641//
642// If loop invariants are used instead of loads, these need to be packed
643// before the loop begins.
644//
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000645bool ARMParallelDSP::MatchSMLAD(Function &F) {
646 BasicBlock *Header = L->getHeader();
647 LLVM_DEBUG(dbgs() << "= Matching SMLAD =\n";
648 dbgs() << "Header block:\n"; Header->dump();
649 dbgs() << "Loop info:\n\n"; L->dump());
650
Eli Friedmanb09c7782018-10-18 19:34:30 +0000651 bool Changed = false;
Sam Parker89a37992018-07-23 15:25:59 +0000652 ReductionList Reductions;
653 MatchReductions(F, L, Header, Reductions);
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000654
655 for (auto &R : Reductions) {
Sam Parker89a37992018-07-23 15:25:59 +0000656 OpChainList MACCandidates;
657 MatchParallelMACSequences(R, MACCandidates);
Eli Friedmanb09c7782018-10-18 19:34:30 +0000658 if (!CheckMACMemory(MACCandidates))
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000659 continue;
Sam Parker89a37992018-07-23 15:25:59 +0000660
Fangrui Song58407ca2018-07-23 17:43:21 +0000661 R.MACCandidates = std::move(MACCandidates);
Sjoerd Meijer53449da2018-07-11 12:36:25 +0000662
663 LLVM_DEBUG(dbgs() << "MAC candidates:\n";
664 for (auto &M : R.MACCandidates)
Sam Parker89a37992018-07-23 15:25:59 +0000665 M->Root->dump();
Sjoerd Meijer53449da2018-07-11 12:36:25 +0000666 dbgs() << "\n";);
667 }
668
669 // Collect all instructions that may read or write memory. Our alias
670 // analysis checks bail out if any of these instructions aliases with an
671 // instruction from the MAC-chain.
672 Instructions Reads, Writes;
673 AliasCandidates(Header, Reads, Writes);
674
675 for (auto &R : Reductions) {
676 if (AreAliased(AA, Reads, Writes, R.MACCandidates))
677 return false;
Sam Parker453ba912018-11-09 09:18:00 +0000678 CreateParallelMACPairs(R);
679 Changed |= InsertParallelMACs(R);
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000680 }
681
682 LLVM_DEBUG(if (Changed) dbgs() << "Header block:\n"; Header->dump(););
683 return Changed;
684}
685
Sam Parker4c4ff132019-03-14 11:14:13 +0000686LoadInst* ARMParallelDSP::CreateLoadIns(IRBuilder<NoFolder> &IRB,
687 SmallVectorImpl<LoadInst*> &Loads,
688 IntegerType *LoadTy) {
689 assert(Loads.size() == 2 && "currently only support widening two loads");
690
691 const unsigned AddrSpace = Loads[0]->getPointerAddressSpace();
692 Value *VecPtr = IRB.CreateBitCast(Loads[0]->getPointerOperand(),
Eli Friedmanb09c7782018-10-18 19:34:30 +0000693 LoadTy->getPointerTo(AddrSpace));
Sam Parker4c4ff132019-03-14 11:14:13 +0000694 LoadInst *WideLoad = IRB.CreateAlignedLoad(LoadTy, VecPtr,
695 Loads[0]->getAlignment());
696 // Fix up users, Loads[0] needs trunc while Loads[1] needs a lshr and trunc.
697 Instruction *SExt0 = dyn_cast<SExtInst>(Loads[0]->user_back());
698 Instruction *SExt1 = dyn_cast<SExtInst>(Loads[1]->user_back());
699
700 assert((Loads[0]->hasOneUse() && Loads[1]->hasOneUse() && SExt0 && SExt1) &&
701 "Loads should have a single, extending, user");
702
703 std::function<void(Instruction*, Instruction*)> MoveAfter =
704 [&](Instruction* Source, Instruction* Sink) -> void {
705 if (DT->dominates(Source, Sink) ||
706 Source->getParent() != Sink->getParent() ||
707 isa<PHINode>(Source) || isa<PHINode>(Sink))
708 return;
709
710 Sink->moveAfter(Source);
711 for (auto &U : Sink->uses())
712 MoveAfter(Sink, cast<Instruction>(U.getUser()));
713 };
714
715 // From the wide load, create two values that equal the original two loads.
716 Value *Bottom = IRB.CreateTrunc(WideLoad, Loads[0]->getType());
717 SExt0->setOperand(0, Bottom);
718 if (auto *I = dyn_cast<Instruction>(Bottom)) {
719 I->moveAfter(WideLoad);
720 MoveAfter(I, SExt0);
721 }
722
723 IntegerType *Ld1Ty = cast<IntegerType>(Loads[1]->getType());
724 Value *ShiftVal = ConstantInt::get(LoadTy, Ld1Ty->getBitWidth());
725 Value *Top = IRB.CreateLShr(WideLoad, ShiftVal);
726 if (auto *I = dyn_cast<Instruction>(Top))
727 MoveAfter(WideLoad, I);
728
729 Value *Trunc = IRB.CreateTrunc(Top, Ld1Ty);
730 SExt1->setOperand(0, Trunc);
731 if (auto *I = dyn_cast<Instruction>(Trunc))
732 MoveAfter(I, SExt1);
733
734 WideLoads.emplace(std::make_pair(Loads[0],
735 make_unique<WidenedLoad>(Loads, WideLoad)));
736 return WideLoad;
Eli Friedmanb09c7782018-10-18 19:34:30 +0000737}
738
Sam Parker4c4ff132019-03-14 11:14:13 +0000739Instruction *ARMParallelDSP::CreateSMLADCall(SmallVectorImpl<LoadInst*> &VecLd0,
740 SmallVectorImpl<LoadInst*> &VecLd1,
Sam Parkera023c7a2018-09-12 09:17:44 +0000741 Instruction *Acc, bool Exchange,
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000742 Instruction *InsertAfter) {
Sam Parkera023c7a2018-09-12 09:17:44 +0000743 LLVM_DEBUG(dbgs() << "Create SMLAD intrinsic using:\n"
Sam Parker4c4ff132019-03-14 11:14:13 +0000744 << "- " << *VecLd0[0] << "\n"
745 << "- " << *VecLd0[1] << "\n"
746 << "- " << *VecLd1[0] << "\n"
747 << "- " << *VecLd1[1] << "\n"
Sam Parkera023c7a2018-09-12 09:17:44 +0000748 << "- " << *Acc << "\n"
Sam Parker4c4ff132019-03-14 11:14:13 +0000749 << "- Exchange: " << Exchange << "\n");
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000750
751 IRBuilder<NoFolder> Builder(InsertAfter->getParent(),
752 ++BasicBlock::iterator(InsertAfter));
753
754 // Replace the reduction chain with an intrinsic call
Sam Parker4c4ff132019-03-14 11:14:13 +0000755 IntegerType *Ty = IntegerType::get(M->getContext(), 32);
756 LoadInst *WideLd0 = WideLoads.count(VecLd0[0]) ?
757 WideLoads[VecLd0[0]]->getLoad() : CreateLoadIns(Builder, VecLd0, Ty);
758 LoadInst *WideLd1 = WideLoads.count(VecLd1[0]) ?
759 WideLoads[VecLd1[0]]->getLoad() : CreateLoadIns(Builder, VecLd1, Ty);
760 Value* Args[] = { WideLd0, WideLd1, Acc };
Sam Parkera023c7a2018-09-12 09:17:44 +0000761 Function *SMLAD = nullptr;
762 if (Exchange)
763 SMLAD = Acc->getType()->isIntegerTy(32) ?
764 Intrinsic::getDeclaration(M, Intrinsic::arm_smladx) :
765 Intrinsic::getDeclaration(M, Intrinsic::arm_smlaldx);
766 else
767 SMLAD = Acc->getType()->isIntegerTy(32) ?
768 Intrinsic::getDeclaration(M, Intrinsic::arm_smlad) :
769 Intrinsic::getDeclaration(M, Intrinsic::arm_smlald);
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000770 CallInst *Call = Builder.CreateCall(SMLAD, Args);
Sjoerd Meijerb3e06fa2018-07-06 14:47:09 +0000771 NumSMLAD++;
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000772 return Call;
773}
774
Sam Parker453ba912018-11-09 09:18:00 +0000775// Compare the value lists in Other to this chain.
776bool BinOpChain::AreSymmetrical(BinOpChain *Other) {
777 // Element-by-element comparison of Value lists returning true if they are
778 // instructions with the same opcode or constants with the same value.
779 auto CompareValueList = [](const ValueList &VL0,
780 const ValueList &VL1) {
781 if (VL0.size() != VL1.size()) {
782 LLVM_DEBUG(dbgs() << "Muls are mismatching operand list lengths: "
783 << VL0.size() << " != " << VL1.size() << "\n");
784 return false;
785 }
786
787 const unsigned Pairs = VL0.size();
Sam Parker453ba912018-11-09 09:18:00 +0000788
789 for (unsigned i = 0; i < Pairs; ++i) {
790 const Value *V0 = VL0[i];
791 const Value *V1 = VL1[i];
792 const auto *Inst0 = dyn_cast<Instruction>(V0);
793 const auto *Inst1 = dyn_cast<Instruction>(V1);
794
Sam Parker453ba912018-11-09 09:18:00 +0000795 if (!Inst0 || !Inst1)
796 return false;
797
Sam Parker4c4ff132019-03-14 11:14:13 +0000798 if (Inst0->isSameOperationAs(Inst1))
Sam Parker453ba912018-11-09 09:18:00 +0000799 continue;
Sam Parker453ba912018-11-09 09:18:00 +0000800
801 const APInt *C0, *C1;
802 if (!(match(V0, m_APInt(C0)) && match(V1, m_APInt(C1)) && C0 == C1))
803 return false;
804 }
805
Sam Parker453ba912018-11-09 09:18:00 +0000806 return true;
807 };
808
809 return CompareValueList(LHS, Other->LHS) &&
810 CompareValueList(RHS, Other->RHS);
811}
812
Sjoerd Meijerc89ca552018-06-28 12:55:29 +0000813Pass *llvm::createARMParallelDSPPass() {
814 return new ARMParallelDSP();
815}
816
817char ARMParallelDSP::ID = 0;
818
Sjoerd Meijerb3e06fa2018-07-06 14:47:09 +0000819INITIALIZE_PASS_BEGIN(ARMParallelDSP, "arm-parallel-dsp",
Simon Pilgrimc09b5e32018-06-28 18:37:16 +0000820 "Transform loops to use DSP intrinsics", false, false)
Sjoerd Meijerb3e06fa2018-07-06 14:47:09 +0000821INITIALIZE_PASS_END(ARMParallelDSP, "arm-parallel-dsp",
Simon Pilgrimc09b5e32018-06-28 18:37:16 +0000822 "Transform loops to use DSP intrinsics", false, false)