@@ -3601,14 +3601,10 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
36013601 return std::make_unique<Dependence>(Src, Dst);
36023602 }
36033603
3604- assert (isLoadOrStore (Src) && " instruction is not load or store" );
3605- assert (isLoadOrStore (Dst) && " instruction is not load or store" );
3606- Value *SrcPtr = getLoadStorePointerOperand (Src);
3607- Value *DstPtr = getLoadStorePointerOperand (Dst);
3604+ const MemoryLocation &LocA = MemoryLocation::get (Dst);
3605+ const MemoryLocation &LocB = MemoryLocation::get (Src);
36083606
3609- switch (underlyingObjectsAlias (AA, F->getDataLayout (),
3610- MemoryLocation::get (Dst),
3611- MemoryLocation::get (Src))) {
3607+ switch (underlyingObjectsAlias (AA, F->getDataLayout (), LocA, LocB)) {
36123608 case AliasResult::MayAlias:
36133609 case AliasResult::PartialAlias:
36143610 // cannot analyse objects if we don't understand their aliasing.
@@ -3622,6 +3618,13 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
36223618 break ; // The underlying objects alias; test accesses for dependence.
36233619 }
36243620
3621+ if (LocA.Size != LocB.Size ) {
3622+ // The dependence test gets confused if the size of the memory accesses
3623+ // differ.
3624+ LLVM_DEBUG (dbgs () << " can't analyze must alias with different sizes\n " );
3625+ return std::make_unique<Dependence>(Src, Dst);
3626+ }
3627+
36253628 // establish loop nesting levels
36263629 establishNestingLevels (Src, Dst);
36273630 LLVM_DEBUG (dbgs () << " common nesting levels = " << CommonLevels << " \n " );
@@ -3632,6 +3635,8 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
36323635
36333636 unsigned Pairs = 1 ;
36343637 SmallVector<Subscript, 2 > Pair (Pairs);
3638+ Value *SrcPtr = getLoadStorePointerOperand (Src);
3639+ Value *DstPtr = getLoadStorePointerOperand (Dst);
36353640 const SCEV *SrcSCEV = SE->getSCEV (SrcPtr);
36363641 const SCEV *DstSCEV = SE->getSCEV (DstPtr);
36373642 LLVM_DEBUG (dbgs () << " SrcSCEV = " << *SrcSCEV << " \n " );
0 commit comments