@@ -3602,14 +3602,10 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
36023602 return std::make_unique<Dependence>(Src, Dst);
36033603 }
36043604
3605- assert (isLoadOrStore (Src) && " instruction is not load or store" );
3606- assert (isLoadOrStore (Dst) && " instruction is not load or store" );
3607- Value *SrcPtr = getLoadStorePointerOperand (Src);
3608- Value *DstPtr = getLoadStorePointerOperand (Dst);
3605+ const MemoryLocation &DstLoc = MemoryLocation::get (Dst);
3606+ const MemoryLocation &SrcLoc = MemoryLocation::get (Src);
36093607
3610- switch (underlyingObjectsAlias (AA, F->getDataLayout (),
3611- MemoryLocation::get (Dst),
3612- MemoryLocation::get (Src))) {
3608+ switch (underlyingObjectsAlias (AA, F->getDataLayout (), DstLoc, SrcLoc)) {
36133609 case AliasResult::MayAlias:
36143610 case AliasResult::PartialAlias:
36153611 // cannot analyse objects if we don't understand their aliasing.
@@ -3623,16 +3619,15 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
36233619 break ; // The underlying objects alias; test accesses for dependence.
36243620 }
36253621
3626- // establish loop nesting levels
3627- establishNestingLevels (Src, Dst);
3628- LLVM_DEBUG (dbgs () << " common nesting levels = " << CommonLevels << " \n " );
3629- LLVM_DEBUG (dbgs () << " maximum nesting levels = " << MaxLevels << " \n " );
3630-
3631- FullDependence Result (Src, Dst, PossiblyLoopIndependent, CommonLevels);
3632- ++TotalArrayPairs;
3622+ if (DstLoc.Size != SrcLoc.Size ) {
3623+ // The dependence test gets confused if the size of the memory accesses
3624+ // differ.
3625+ LLVM_DEBUG (dbgs () << " can't analyze must alias with different sizes\n " );
3626+ return std::make_unique<Dependence>(Src, Dst);
3627+ }
36333628
3634- unsigned Pairs = 1 ;
3635- SmallVector<Subscript, 2 > Pair (Pairs );
3629+ Value *SrcPtr = getLoadStorePointerOperand (Src) ;
3630+ Value *DstPtr = getLoadStorePointerOperand (Dst );
36363631 const SCEV *SrcSCEV = SE->getSCEV (SrcPtr);
36373632 const SCEV *DstSCEV = SE->getSCEV (DstPtr);
36383633 LLVM_DEBUG (dbgs () << " SrcSCEV = " << *SrcSCEV << " \n " );
@@ -3647,6 +3642,17 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
36473642 LLVM_DEBUG (dbgs () << " can't analyze SCEV with different pointer base\n " );
36483643 return std::make_unique<Dependence>(Src, Dst);
36493644 }
3645+
3646+ // establish loop nesting levels
3647+ establishNestingLevels (Src, Dst);
3648+ LLVM_DEBUG (dbgs () << " common nesting levels = " << CommonLevels << " \n " );
3649+ LLVM_DEBUG (dbgs () << " maximum nesting levels = " << MaxLevels << " \n " );
3650+
3651+ FullDependence Result (Src, Dst, PossiblyLoopIndependent, CommonLevels);
3652+ ++TotalArrayPairs;
3653+
3654+ unsigned Pairs = 1 ;
3655+ SmallVector<Subscript, 2 > Pair (Pairs);
36503656 Pair[0 ].Src = SrcSCEV;
36513657 Pair[0 ].Dst = DstSCEV;
36523658
0 commit comments