Index: lib/Analysis/LoopAccessAnalysis.cpp =================================================================== --- lib/Analysis/LoopAccessAnalysis.cpp +++ lib/Analysis/LoopAccessAnalysis.cpp @@ -1268,7 +1268,10 @@ // Write to the same location with the same size. // Could be improved to assert type sizes are the same (i32 == float, etc). if (Val == 0) { - if (ATy == BTy) + if (ATy == BTy || + // Handle the case of different types in the smae size + (ATy->getPrimitiveSizeInBits() == BTy->getPrimitiveSizeInBits() && + ATy->getPrimitiveSizeInBits() > 0)) return Dependence::Forward; DEBUG(dbgs() << "LAA: Zero dependence difference but different types\n"); return Dependence::Unknown; Index: test/Analysis/LoopAccessAnalysis/same_size_different_type.ll =================================================================== --- test/Analysis/LoopAccessAnalysis/same_size_different_type.ll +++ test/Analysis/LoopAccessAnalysis/same_size_different_type.ll @@ -0,0 +1,41 @@ +; RUN: opt -loop-accesses -analyze < %s | FileCheck %s +; +; We expect there exist only one anti-dep in this loop. +; +; for (int i=0;i +; CHECK-NEXT: store double 0.000000e+00, double* %arrayidx, align 8 +; CHECK-NOT: Forward: +entry: + br label %for.body + +for.cond.cleanup: ; preds = %for.body + ret void + +for.body: ; preds = %for.body, %entry + %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] + %arrayidx = getelementptr inbounds [1000 x double], [1000 x double]* @c, i64 0, i64 %indvars.iv + %0 = bitcast double* %arrayidx to i64* + %1 = load i64, i64* %0, align 8 + %arrayidx2 = getelementptr inbounds [1000 x double], [1000 x double]* @b, i64 0, i64 %indvars.iv + %2 = bitcast double* %arrayidx2 to i64* + store i64 %1, i64* %2, align 8 + store double 0.000000e+00, double* %arrayidx, align 8 + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 + %exitcond = icmp eq i64 %indvars.iv.next, 1000 + br i1 %exitcond, label %for.cond.cleanup, label %for.body +}