diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-11-02 08:33:25 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-11-02 08:33:25 +0000 |
commit | a864748284f4bab974ffb13b840a611c1f9bc7ac (patch) | |
tree | efa83992f67fa1c80bc3023a0c357bb0627852f7 /test/Transforms/LoopIdiom | |
parent | d295c9729d04727666c84c4a184e8ce796dd9974 (diff) | |
download | external_llvm-a864748284f4bab974ffb13b840a611c1f9bc7ac.zip external_llvm-a864748284f4bab974ffb13b840a611c1f9bc7ac.tar.gz external_llvm-a864748284f4bab974ffb13b840a611c1f9bc7ac.tar.bz2 |
Revert the switch of loop-idiom to use the new dependence analysis.
The new analysis is not yet ready for prime time. It has a *critical*
flawed assumption, and some troubling shortages of testing. Until it's
been hammered into better shape, let's stick with the working code. This
should be easy to revert itself when the analysis is ready.
Fixes PR14241, a miscompile of any memcpy-able loop which uses a pointer
as the induction mechanism. If you have been seeing miscompiles in this
revision range, you really want to test with this backed out. The
results of this miscompile are a bit subtle as they can lead to
downstream passes concluding things are impossible which are in fact
possible.
Thanks to David Blaikie for the majority of the reduction of this
miscompile. I'll be checking in the test case in a non-revert commit.
Revesions reverted here:
r167045: LoopIdiom: Fix a serious missed optimization: we only turned
top-level loops into memmove.
r166877: LoopIdiom: Add checks to avoid turning memmove into an infinite
loop.
r166875: LoopIdiom: Recognize memmove loops.
r166874: LoopIdiom: Replace custom dependence analysis with
DependenceAnalysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167286 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/LoopIdiom')
-rw-r--r-- | test/Transforms/LoopIdiom/basic.ll | 22 | ||||
-rw-r--r-- | test/Transforms/LoopIdiom/memmove.ll | 42 | ||||
-rw-r--r-- | test/Transforms/LoopIdiom/memset_noidiom.ll | 53 | ||||
-rw-r--r-- | test/Transforms/LoopIdiom/multi-dimensional.ll | 49 | ||||
-rw-r--r-- | test/Transforms/LoopIdiom/sideeffect.ll | 53 |
5 files changed, 1 insertions, 218 deletions
diff --git a/test/Transforms/LoopIdiom/basic.ll b/test/Transforms/LoopIdiom/basic.ll index 5afc405..46ab7e5 100644 --- a/test/Transforms/LoopIdiom/basic.ll +++ b/test/Transforms/LoopIdiom/basic.ll @@ -383,26 +383,4 @@ for.end: ; preds = %for.inc } -@p = common global [1024 x i8] zeroinitializer, align 16 -define void @test15(i32 %n) nounwind { -entry: - %cmp6 = icmp eq i32 %n, 0 - br i1 %cmp6, label %for.end, label %for.body - -for.body: ; preds = %entry, %for.body - %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] - %indvars.iv.next = add i64 %indvars.iv, 1 - %arrayidx = getelementptr inbounds [1024 x i8]* @p, i64 0, i64 %indvars.iv.next - %0 = load i8* %arrayidx, align 1 - %arrayidx2 = getelementptr inbounds [1024 x i8]* @p, i64 0, i64 %indvars.iv - store i8 %0, i8* %arrayidx2, align 1 - %lftr.wideiv = trunc i64 %indvars.iv.next to i32 - %exitcond = icmp eq i32 %lftr.wideiv, %n - br i1 %exitcond, label %for.end, label %for.body - -for.end: ; preds = %for.body, %entry - ret void -; CHECK: @test15 -; CHECK: call void @llvm.memmove.p0i8.p0i8.i64(i8* getelementptr inbounds ([1024 x i8]* @p, i32 0, i32 0), i8* getelementptr inbounds ([1024 x i8]* @p, i64 0, i64 1), -} diff --git a/test/Transforms/LoopIdiom/memmove.ll b/test/Transforms/LoopIdiom/memmove.ll deleted file mode 100644 index bfa0902..0000000 --- a/test/Transforms/LoopIdiom/memmove.ll +++ /dev/null @@ -1,42 +0,0 @@ -; RUN: opt -S -basicaa -loop-idiom < %s | FileCheck %s -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" -target triple = "x86_64-apple-macosx10.8.0" - -declare i64 @foo() nounwind - -; Nested loops -define void @test1(i8* nocapture %A, i64 %n) nounwind { -entry: - %call8 = tail call i64 @foo() nounwind - %tobool9 = icmp eq i64 %call8, 0 - br i1 %tobool9, label %while.end, label %for.cond.preheader.lr.ph - -for.cond.preheader.lr.ph: ; preds = %entry - %cmp6 = icmp eq i64 %n, 0 - br label %for.cond.preheader - -while.cond.loopexit: ; preds = %for.body, %for.cond.preheader - %call = tail call i64 @foo() nounwind - %tobool = icmp eq i64 %call, 0 - br i1 %tobool, label %while.end, label %for.cond.preheader - -for.cond.preheader: ; preds = %for.cond.preheader.lr.ph, %while.cond.loopexit - br i1 %cmp6, label %while.cond.loopexit, label %for.body - -for.body: ; preds = %for.cond.preheader, %for.body - %i.07 = phi i64 [ %inc, %for.body ], [ 0, %for.cond.preheader ] - %add = add i64 %i.07, 10 - %arrayidx = getelementptr inbounds i8* %A, i64 %add - %0 = load i8* %arrayidx, align 1 - %arrayidx1 = getelementptr inbounds i8* %A, i64 %i.07 - store i8 %0, i8* %arrayidx1, align 1 - %inc = add i64 %i.07, 1 - %exitcond = icmp eq i64 %inc, %n - br i1 %exitcond, label %while.cond.loopexit, label %for.body - -while.end: ; preds = %while.cond.loopexit, %entry - ret void - -; CHECK: @test1 -; CHECK: call void @llvm.memmove.p0i8.p0i8.i64( -} diff --git a/test/Transforms/LoopIdiom/memset_noidiom.ll b/test/Transforms/LoopIdiom/memset_noidiom.ll index 27ef4f6..168eb95 100644 --- a/test/Transforms/LoopIdiom/memset_noidiom.ll +++ b/test/Transforms/LoopIdiom/memset_noidiom.ll @@ -1,4 +1,4 @@ -; RUN: opt -basicaa -loop-idiom < %s -S | FileCheck %s +; RUN: opt -loop-idiom < %s -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-apple-darwin10.0.0" @@ -28,54 +28,3 @@ for.end: ; preds = %for.cond.for.end_cr ret i8* %b } -; CHECK: @memcpy -; CHECK-NOT: llvm.memcpy -define i8* @memcpy(i8* noalias %dst, i8* noalias %src, i64 %n) nounwind { -entry: - %tobool3 = icmp eq i64 %n, 0 - br i1 %tobool3, label %while.end, label %while.body - -while.body: ; preds = %entry, %while.body - %c2.06 = phi i8* [ %incdec.ptr, %while.body ], [ %src, %entry ] - %c1.05 = phi i8* [ %incdec.ptr1, %while.body ], [ %dst, %entry ] - %n.addr.04 = phi i64 [ %dec, %while.body ], [ %n, %entry ] - %dec = add i64 %n.addr.04, -1 - %incdec.ptr = getelementptr inbounds i8* %c2.06, i64 1 - %0 = load i8* %c2.06, align 1 - %incdec.ptr1 = getelementptr inbounds i8* %c1.05, i64 1 - store i8 %0, i8* %c1.05, align 1 - %tobool = icmp eq i64 %dec, 0 - br i1 %tobool, label %while.end, label %while.body - -while.end: ; preds = %while.body, %entry - ret i8* %dst -} - -; CHECK: @memmove -; CHECK-NOT: llvm.memmove -define i8* @memmove(i8* %dst, i8* nocapture %src, i64 %count) nounwind { -entry: - %sub = add i64 %count, -1 - %tobool9 = icmp eq i64 %count, 0 - br i1 %tobool9, label %while.end, label %while.body.lr.ph - -while.body.lr.ph: ; preds = %entry - %add.ptr2 = getelementptr inbounds i8* %src, i64 %sub - %add.ptr = getelementptr inbounds i8* %dst, i64 %sub - br label %while.body - -while.body: ; preds = %while.body.lr.ph, %while.body - %b.012 = phi i8* [ %add.ptr2, %while.body.lr.ph ], [ %incdec.ptr, %while.body ] - %a.011 = phi i8* [ %add.ptr, %while.body.lr.ph ], [ %incdec.ptr3, %while.body ] - %count.addr.010 = phi i64 [ %count, %while.body.lr.ph ], [ %dec, %while.body ] - %dec = add i64 %count.addr.010, -1 - %incdec.ptr = getelementptr inbounds i8* %b.012, i64 -1 - %0 = load i8* %b.012, align 1 - %incdec.ptr3 = getelementptr inbounds i8* %a.011, i64 -1 - store i8 %0, i8* %a.011, align 1 - %tobool = icmp eq i64 %dec, 0 - br i1 %tobool, label %while.end, label %while.body - -while.end: ; preds = %while.body, %entry - ret i8* %dst -} diff --git a/test/Transforms/LoopIdiom/multi-dimensional.ll b/test/Transforms/LoopIdiom/multi-dimensional.ll deleted file mode 100644 index 991f268..0000000 --- a/test/Transforms/LoopIdiom/multi-dimensional.ll +++ /dev/null @@ -1,49 +0,0 @@ -; RUN: opt -basicaa -loop-idiom < %s -S | FileCheck %s -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" -target triple = "x86_64-apple-darwin10.0.0" - -%struct.ham = type { [2 x [2 x [2 x [16 x [8 x i32]]]]], i32, %struct.zot } -%struct.zot = type { i32, i16, i16, [2 x [1152 x i32]] } - -define void @test1(%struct.ham* nocapture %arg) nounwind { -bb: - br label %bb1 - -bb1: ; preds = %bb11, %bb - %tmp = phi i64 [ 0, %bb ], [ %tmp12, %bb11 ] - br label %bb2 - -bb2: ; preds = %bb2, %bb1 - %tmp3 = phi i64 [ 0, %bb1 ], [ %tmp8, %bb2 ] - %tmp4 = getelementptr inbounds %struct.ham* %arg, i64 0, i32 0, i64 0, i64 1, i64 1, i64 %tmp, i64 %tmp3 - store i32 0, i32* %tmp4, align 4 - %tmp5 = getelementptr inbounds %struct.ham* %arg, i64 0, i32 0, i64 0, i64 1, i64 0, i64 %tmp, i64 %tmp3 - store i32 0, i32* %tmp5, align 4 - %tmp6 = getelementptr inbounds %struct.ham* %arg, i64 0, i32 0, i64 0, i64 0, i64 1, i64 %tmp, i64 %tmp3 - store i32 0, i32* %tmp6, align 4 - %tmp7 = getelementptr inbounds %struct.ham* %arg, i64 0, i32 0, i64 0, i64 0, i64 0, i64 %tmp, i64 %tmp3 - store i32 0, i32* %tmp7, align 4 - %tmp8 = add i64 %tmp3, 1 - %tmp9 = trunc i64 %tmp8 to i32 - %tmp10 = icmp eq i32 %tmp9, 8 - br i1 %tmp10, label %bb11, label %bb2 - -bb11: ; preds = %bb2 - %tmp12 = add i64 %tmp, 1 - %tmp13 = trunc i64 %tmp12 to i32 - %tmp14 = icmp eq i32 %tmp13, 16 - br i1 %tmp14, label %bb15, label %bb1 - -bb15: ; preds = %bb11 - ret void - -; CHECK: @test1 -; CHECK: bb1: -; CHECK-NOT: store -; CHECK: call void @llvm.memset.p0i8.i64 -; CHECK-NEXT: call void @llvm.memset.p0i8.i64 -; CHECK-NEXT: call void @llvm.memset.p0i8.i64 -; CHECK-NEXT: call void @llvm.memset.p0i8.i64 -; CHECK-NOT: store -; CHECK: br -} diff --git a/test/Transforms/LoopIdiom/sideeffect.ll b/test/Transforms/LoopIdiom/sideeffect.ll deleted file mode 100644 index 460e523..0000000 --- a/test/Transforms/LoopIdiom/sideeffect.ll +++ /dev/null @@ -1,53 +0,0 @@ -; RUN: opt -basicaa -loop-idiom < %s -S | FileCheck %s -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" -target triple = "x86_64-apple-darwin10.0.0" - -; PR9481 -define i32 @test1() nounwind uwtable ssp { -entry: - %a = alloca [10 x i8], align 1 - br label %for.body - -for.cond1.preheader: ; preds = %for.body - %arrayidx5.phi.trans.insert = getelementptr inbounds [10 x i8]* %a, i64 0, i64 0 - %.pre = load i8* %arrayidx5.phi.trans.insert, align 1 - br label %for.body3 - -for.body: ; preds = %for.body, %entry - %indvars.iv29 = phi i64 [ 0, %entry ], [ %indvars.iv.next30, %for.body ] - call void (...)* @bar() nounwind - %arrayidx = getelementptr inbounds [10 x i8]* %a, i64 0, i64 %indvars.iv29 - store i8 23, i8* %arrayidx, align 1 - %indvars.iv.next30 = add i64 %indvars.iv29, 1 - %lftr.wideiv31 = trunc i64 %indvars.iv.next30 to i32 - %exitcond32 = icmp eq i32 %lftr.wideiv31, 1000000 - br i1 %exitcond32, label %for.cond1.preheader, label %for.body - -for.body3: ; preds = %for.body3, %for.cond1.preheader - %0 = phi i8 [ %.pre, %for.cond1.preheader ], [ %add, %for.body3 ] - %indvars.iv = phi i64 [ 1, %for.cond1.preheader ], [ %indvars.iv.next, %for.body3 ] - call void (...)* @bar() nounwind - %arrayidx7 = getelementptr inbounds [10 x i8]* %a, i64 0, i64 %indvars.iv - %1 = load i8* %arrayidx7, align 1 - %add = add i8 %1, %0 - store i8 %add, i8* %arrayidx7, align 1 - %indvars.iv.next = add i64 %indvars.iv, 1 - %lftr.wideiv = trunc i64 %indvars.iv.next to i32 - %exitcond = icmp eq i32 %lftr.wideiv, 1000000 - br i1 %exitcond, label %for.end12, label %for.body3 - -for.end12: ; preds = %for.body3 - %arrayidx13 = getelementptr inbounds [10 x i8]* %a, i64 0, i64 2 - %2 = load i8* %arrayidx13, align 1 - %conv14 = sext i8 %2 to i32 - %arrayidx15 = getelementptr inbounds [10 x i8]* %a, i64 0, i64 6 - %3 = load i8* %arrayidx15, align 1 - %conv16 = sext i8 %3 to i32 - %add17 = add nsw i32 %conv16, %conv14 - ret i32 %add17 - -; CHECK: @test1 -; CHECK-NOT: @llvm.memset -} - -declare void @bar(...) |