@@ -45,7 +45,7 @@ namespace {
45
45
using ParallelMACList = SmallVector<ParallelMAC, 8 >;
46
46
using ReductionList = SmallVector<Reduction, 8 >;
47
47
using ValueList = SmallVector<Value*, 8 >;
48
- using LoadInstList = SmallVector<LoadInst *, 8 >;
48
+ using MemInstList = SmallVector<Instruction *, 8 >;
49
49
using PMACPair = std::pair<ParallelMAC*,ParallelMAC*>;
50
50
using PMACPairList = SmallVector<PMACPair, 8 >;
51
51
using Instructions = SmallVector<Instruction*,16 >;
@@ -58,7 +58,7 @@ namespace {
58
58
struct ParallelMAC {
59
59
Instruction *Mul;
60
60
ValueList VL; // List of all (narrow) operands of this Mul
61
- LoadInstList VecLd; // List of all load instructions of this Mul
61
+ MemInstList VecLd; // List of all load instructions of this Mul
62
62
MemLocList MemLocs; // All memory locations read by this Mul
63
63
64
64
ParallelMAC (Instruction *I, ValueList &V) : Mul(I), VL(V) {};
@@ -84,7 +84,7 @@ namespace {
84
84
Module *M;
85
85
86
86
bool InsertParallelMACs (Reduction &Reduction, PMACPairList &PMACPairs);
87
- bool AreSequentialLoads (LoadInst *Ld0, LoadInst *Ld1, LoadInstList &VecLd);
87
+ bool AreSequentialLoads (LoadInst *Ld0, LoadInst *Ld1, MemInstList &VecLd);
88
88
PMACPairList CreateParallelMACPairs (ParallelMACList &Candidates);
89
89
Instruction *CreateSMLADCall (LoadInst *VecLd0, LoadInst *VecLd1,
90
90
Instruction *Acc, Instruction *InsertAfter);
@@ -254,8 +254,26 @@ static bool AreSymmetrical(const ValueList &VL0,
254
254
return true ;
255
255
}
256
256
257
+ template <typename MemInst>
258
+ static bool AreSequentialAccesses (MemInst *MemOp0, MemInst *MemOp1,
259
+ MemInstList &VecMem, const DataLayout &DL,
260
+ ScalarEvolution &SE) {
261
+ if (!MemOp0->isSimple () || !MemOp1->isSimple ()) {
262
+ LLVM_DEBUG (dbgs () << " No, not touching volatile access\n " );
263
+ return false ;
264
+ }
265
+ if (isConsecutiveAccess (MemOp0, MemOp1, DL, SE)) {
266
+ VecMem.push_back (MemOp0);
267
+ VecMem.push_back (MemOp1);
268
+ LLVM_DEBUG (dbgs () << " OK: accesses are consecutive.\n " );
269
+ return true ;
270
+ }
271
+ LLVM_DEBUG (dbgs () << " No, accesses aren't consecutive.\n " );
272
+ return false ;
273
+ }
274
+
257
275
bool ARMParallelDSP::AreSequentialLoads (LoadInst *Ld0, LoadInst *Ld1,
258
- LoadInstList &VecLd ) {
276
+ MemInstList &VecMem ) {
259
277
if (!Ld0 || !Ld1)
260
278
return false ;
261
279
@@ -264,22 +282,12 @@ bool ARMParallelDSP::AreSequentialLoads(LoadInst *Ld0, LoadInst *Ld1,
264
282
dbgs () << " Ld1:" ; Ld1->dump ();
265
283
);
266
284
267
- if (!Ld0->isSimple () || !Ld1->isSimple ()) {
268
- LLVM_DEBUG (dbgs () << " No, not touching volatile loads\n " );
269
- return false ;
270
- }
271
285
if (!Ld0->hasOneUse () || !Ld1->hasOneUse ()) {
272
286
LLVM_DEBUG (dbgs () << " No, load has more than one use.\n " );
273
287
return false ;
274
288
}
275
- if (isConsecutiveAccess (Ld0, Ld1, *DL, *SE)) {
276
- VecLd.push_back (Ld0);
277
- VecLd.push_back (Ld1);
278
- LLVM_DEBUG (dbgs () << " OK: loads are consecutive.\n " );
279
- return true ;
280
- }
281
- LLVM_DEBUG (dbgs () << " No, Ld0 and Ld1 aren't consecutive.\n " );
282
- return false ;
289
+
290
+ return AreSequentialAccesses<LoadInst>(Ld0, Ld1, VecMem, *DL, *SE);
283
291
}
284
292
285
293
PMACPairList
@@ -349,8 +357,9 @@ bool ARMParallelDSP::InsertParallelMACs(Reduction &Reduction,
349
357
LLVM_DEBUG (dbgs () << " Found parallel MACs!!\n " ;
350
358
dbgs () << " - " ; Pair.first ->Mul ->dump ();
351
359
dbgs () << " - " ; Pair.second ->Mul ->dump ());
352
- Acc = CreateSMLADCall (Pair.first ->VecLd [0 ], Pair.second ->VecLd [0 ], Acc,
353
- InsertAfter);
360
+ auto *VecLd0 = cast<LoadInst>(Pair.first ->VecLd [0 ]);
361
+ auto *VecLd1 = cast<LoadInst>(Pair.second ->VecLd [0 ]);
362
+ Acc = CreateSMLADCall (VecLd0, VecLd1, Acc, InsertAfter);
354
363
InsertAfter = Acc;
355
364
}
356
365
0 commit comments