[PATCH] D23686: Improve the LoopAccessAnalysis to handle the different types in the same size
Jin Lin via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 18 11:59:59 PDT 2016
jinlin updated this revision to Diff 68587.
Repository:
rL LLVM
https://reviews.llvm.org/D23686
Files:
lib/Analysis/LoopAccessAnalysis.cpp
test/Analysis/LoopAccessAnalysis/same_size_different_type.ll
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,40 @@
+; RUN: opt -loop-accesses -analyze < %s | FileCheck %s
+;
+; We expect there exist only one anti-dep in this loop.
+;
+; for (int i=0;i<N;i++) {
+; b[i] = c[i];
+; c[i] = 0.0;
+; }
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+ at c = common local_unnamed_addr global [1000 x double] zeroinitializer, align 16
+ at b = common local_unnamed_addr global [1000 x double] zeroinitializer, align 16
+ at a = common local_unnamed_addr global [1000 x double] zeroinitializer, align 16
+
+; Function Attrs: norecurse nounwind uwtable
+define void @foo() local_unnamed_addr {
+; CHECK: Dependences:
+; CHECK-NEXT: Forward:
+; CHECK-NEXT: %1 = load i64, i64* %0, align 8 ->
+; CHECK-NEXT: store double 0.000000e+00, double* %arrayidx, align 8
+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
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23686.68587.patch
Type: text/x-patch
Size: 2632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160818/83b1ff8d/attachment.bin>
More information about the llvm-commits
mailing list