@@ -3604,14 +3604,10 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
36043604 return std::make_unique<Dependence>(Src, Dst);
36053605 }
36063606
3607- assert (isLoadOrStore (Src) && " instruction is not load or store" );
3608- assert (isLoadOrStore (Dst) && " instruction is not load or store" );
3609- Value *SrcPtr = getLoadStorePointerOperand (Src);
3610- Value *DstPtr = getLoadStorePointerOperand (Dst);
3607+ const MemoryLocation &DstLoc = MemoryLocation::get (Dst);
3608+ const MemoryLocation &SrcLoc = MemoryLocation::get (Src);
36113609
3612- switch (underlyingObjectsAlias (AA, F->getDataLayout (),
3613- MemoryLocation::get (Dst),
3614- MemoryLocation::get (Src))) {
3610+ switch (underlyingObjectsAlias (AA, F->getDataLayout (), DstLoc, SrcLoc)) {
36153611 case AliasResult::MayAlias:
36163612 case AliasResult::PartialAlias:
36173613 // cannot analyse objects if we don't understand their aliasing.
@@ -3625,16 +3621,15 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
36253621 break ; // The underlying objects alias; test accesses for dependence.
36263622 }
36273623
3628- // establish loop nesting levels
3629- establishNestingLevels (Src, Dst);
3630- LLVM_DEBUG (dbgs () << " common nesting levels = " << CommonLevels << " \n " );
3631- LLVM_DEBUG (dbgs () << " maximum nesting levels = " << MaxLevels << " \n " );
3632-
3633- FullDependence Result (Src, Dst, PossiblyLoopIndependent, CommonLevels);
3634- ++TotalArrayPairs;
3624+ if (DstLoc.Size != SrcLoc.Size ) {
3625+ // The dependence test gets confused if the size of the memory accesses
3626+ // differ.
3627+ LLVM_DEBUG (dbgs () << " can't analyze must alias with different sizes\n " );
3628+ return std::make_unique<Dependence>(Src, Dst);
3629+ }
36353630
3636- unsigned Pairs = 1 ;
3637- SmallVector<Subscript, 2 > Pair (Pairs );
3631+ Value *SrcPtr = getLoadStorePointerOperand (Src) ;
3632+ Value *DstPtr = getLoadStorePointerOperand (Dst );
36383633 const SCEV *SrcSCEV = SE->getSCEV (SrcPtr);
36393634 const SCEV *DstSCEV = SE->getSCEV (DstPtr);
36403635 LLVM_DEBUG (dbgs () << " SrcSCEV = " << *SrcSCEV << " \n " );
@@ -3649,6 +3644,17 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
36493644 LLVM_DEBUG (dbgs () << " can't analyze SCEV with different pointer base\n " );
36503645 return std::make_unique<Dependence>(Src, Dst);
36513646 }
3647+
3648+ // establish loop nesting levels
3649+ establishNestingLevels (Src, Dst);
3650+ LLVM_DEBUG (dbgs () << " common nesting levels = " << CommonLevels << " \n " );
3651+ LLVM_DEBUG (dbgs () << " maximum nesting levels = " << MaxLevels << " \n " );
3652+
3653+ FullDependence Result (Src, Dst, PossiblyLoopIndependent, CommonLevels);
3654+ ++TotalArrayPairs;
3655+
3656+ unsigned Pairs = 1 ;
3657+ SmallVector<Subscript, 2 > Pair (Pairs);
36523658 Pair[0 ].Src = SrcSCEV;
36533659 Pair[0 ].Dst = DstSCEV;
36543660
0 commit comments