summaryrefslogtreecommitdiff
path: root/test/Transforms/GVN
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/GVN')
-rw-r--r--test/Transforms/GVN/2007-07-25-InfiniteLoop.ll2
-rw-r--r--test/Transforms/GVN/2007-07-26-InterlockingLoops.ll29
-rw-r--r--test/Transforms/GVN/2007-07-31-NoDomInherit.ll2
-rw-r--r--test/Transforms/GVN/2007-07-31-RedundantPhi.ll2
-rw-r--r--test/Transforms/GVN/2008-07-02-Unreachable.ll2
-rw-r--r--test/Transforms/GVN/2010-03-31-RedundantPHIs.ll12
-rw-r--r--test/Transforms/GVN/2010-11-13-Simplify.ll15
-rw-r--r--test/Transforms/GVN/calls-nonlocal.ll2
-rw-r--r--test/Transforms/GVN/condprop.ll35
-rw-r--r--test/Transforms/GVN/invariant-simple.ll2
-rw-r--r--test/Transforms/GVN/lifetime-simple.ll2
-rw-r--r--test/Transforms/GVN/load-constant-mem.ll2
-rw-r--r--test/Transforms/GVN/load-pre-licm.ll39
-rw-r--r--test/Transforms/GVN/lpre-call-wrap-2.ll2
-rw-r--r--test/Transforms/GVN/mixed.ll4
-rw-r--r--test/Transforms/GVN/non-local-offset.ll59
-rw-r--r--test/Transforms/GVN/nonescaping-malloc.ll2
-rw-r--r--test/Transforms/GVN/null-aliases-nothing.ll2
-rw-r--r--test/Transforms/GVN/phi-translate.ll31
-rw-r--r--test/Transforms/GVN/pre-load.ll2
-rw-r--r--test/Transforms/GVN/pre-single-pred.ll14
-rw-r--r--test/Transforms/GVN/preserve-tbaa.ll28
-rw-r--r--test/Transforms/GVN/rle-must-alias.ll2
-rw-r--r--test/Transforms/GVN/rle-nonlocal.ll2
-rw-r--r--test/Transforms/GVN/rle-semidominated.ll2
-rw-r--r--test/Transforms/GVN/rle.ll2
26 files changed, 242 insertions, 56 deletions
diff --git a/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll b/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll
index 2e0a1015caf55..9983374b154e3 100644
--- a/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll
+++ b/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | not grep {tmp10 =}
+; RUN: opt < %s -basicaa -gvn -S | not grep {tmp10 =}
%struct.INT2 = type { i32, i32 }
@blkshifts = external global %struct.INT2* ; <%struct.INT2**> [#uses=2]
diff --git a/test/Transforms/GVN/2007-07-26-InterlockingLoops.ll b/test/Transforms/GVN/2007-07-26-InterlockingLoops.ll
index 0be33791f6170..14cb91b531672 100644
--- a/test/Transforms/GVN/2007-07-26-InterlockingLoops.ll
+++ b/test/Transforms/GVN/2007-07-26-InterlockingLoops.ll
@@ -1,30 +1,33 @@
-; RUN: opt < %s -gvn -S | grep {tmp17625.* = phi i32. }
-; RUN: opt < %s -gvn -S | grep {tmp17631.* = phi i32. }
+; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
-@last = external global [65 x i32*] ; <[65 x i32*]*> [#uses=1]
+@last = external global [65 x i32*]
define i32 @NextRootMove(i32 %wtm) {
-cond_next95: ; preds = %cond_true85, %cond_true79, %cond_true73, %bb68
- %tmp17618 = load i32** getelementptr ([65 x i32*]* @last, i32 0, i32 1), align 4 ; <i32*> [#uses=0]
+entry:
+ %tmp17618 = load i32** getelementptr ([65 x i32*]* @last, i32 0, i32 1), align 4
+; CHECK: entry:
+; CHECK-NEXT: %tmp17618 = load
+; CHECK-NOT: load
+; CHECK-NOT: phi
br label %cond_true116
-cond_true116: ; preds = %cond_true111
+cond_true116:
br i1 false, label %cond_true128, label %cond_true145
-cond_true128: ; preds = %cond_true121
- %tmp17625 = load i32** getelementptr ([65 x i32*]* @last, i32 0, i32 1), align 4 ; <i32*> [#uses=0]
+cond_true128:
+ %tmp17625 = load i32** getelementptr ([65 x i32*]* @last, i32 0, i32 1), align 4
br i1 false, label %bb98.backedge, label %return.loopexit
-bb98.backedge: ; preds = %bb171, %cond_true145, %cond_true128
+bb98.backedge:
br label %cond_true116
-cond_true145: ; preds = %cond_false
- %tmp17631 = load i32** getelementptr ([65 x i32*]* @last, i32 0, i32 1), align 4 ; <i32*> [#uses=0]
+cond_true145:
+ %tmp17631 = load i32** getelementptr ([65 x i32*]* @last, i32 0, i32 1), align 4
br i1 false, label %bb98.backedge, label %return.loopexit
-return.loopexit: ; preds = %bb171, %cond_true145, %cond_true128
+return.loopexit:
br label %return
-return: ; preds = %return.loopexit, %cond_next95, %cond_true85
+return:
ret i32 0
}
diff --git a/test/Transforms/GVN/2007-07-31-NoDomInherit.ll b/test/Transforms/GVN/2007-07-31-NoDomInherit.ll
index faa1157dd8be1..f2c001296f63f 100644
--- a/test/Transforms/GVN/2007-07-31-NoDomInherit.ll
+++ b/test/Transforms/GVN/2007-07-31-NoDomInherit.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | grep {tmp47 = phi i32 }
+; RUN: opt < %s -basicaa -gvn -S | grep {tmp47 = phi i32 }
%struct.anon = type { i32 (i32, i32, i32)*, i32, i32, [3 x i32], i8*, i8*, i8* }
@debug = external constant i32 ; <i32*> [#uses=0]
diff --git a/test/Transforms/GVN/2007-07-31-RedundantPhi.ll b/test/Transforms/GVN/2007-07-31-RedundantPhi.ll
index 0d1d8bced0003..a570e3571ee0c 100644
--- a/test/Transforms/GVN/2007-07-31-RedundantPhi.ll
+++ b/test/Transforms/GVN/2007-07-31-RedundantPhi.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | not grep {tmp701 =}
+; RUN: opt < %s -basicaa -gvn -S | not grep {tmp701 =}
@img_width = external global i16 ; <i16*> [#uses=2]
diff --git a/test/Transforms/GVN/2008-07-02-Unreachable.ll b/test/Transforms/GVN/2008-07-02-Unreachable.ll
index 361c1557f24f8..be69cfc0319ce 100644
--- a/test/Transforms/GVN/2008-07-02-Unreachable.ll
+++ b/test/Transforms/GVN/2008-07-02-Unreachable.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | grep {ret i8 \[%\]tmp3}
+; RUN: opt < %s -basicaa -gvn -S | grep {ret i8 \[%\]tmp3}
; PR2503
@g_3 = external global i8 ; <i8*> [#uses=2]
diff --git a/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll b/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll
index 066e3038b0877..d6e1c6b76d0b3 100644
--- a/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll
+++ b/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll
@@ -1,4 +1,7 @@
-; RUN: opt < %s -gvn -enable-full-load-pre -S | FileCheck %s
+; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
+
+; CHECK-NOT: load
+; CHECK-NOT: phi
define i8* @cat(i8* %s1, ...) nounwind {
entry:
@@ -29,18 +32,11 @@ bb10: ; preds = %bb8
br label %bb11
bb11: ; preds = %bb10, %bb9
-; CHECK: bb11:
-; CHECK: phi
-; CHECK-NOT: phi
br label %bb12
bb12: ; preds = %bb11, %bb6
-; CHECK: bb12:
-; CHECK: phi
-; CHECK-NOT: phi
br i1 undef, label %bb8, label %bb13
bb13: ; preds = %bb12
-; CHECK: bb13:
ret i8* undef
}
diff --git a/test/Transforms/GVN/2010-11-13-Simplify.ll b/test/Transforms/GVN/2010-11-13-Simplify.ll
new file mode 100644
index 0000000000000..07585a20b6ca5
--- /dev/null
+++ b/test/Transforms/GVN/2010-11-13-Simplify.ll
@@ -0,0 +1,15 @@
+; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
+
+declare i32 @foo(i32) readnone
+
+define i1 @bar() {
+; CHECK: @bar
+ %a = call i32 @foo (i32 0) readnone
+ %b = call i32 @foo (i32 0) readnone
+ %c = and i32 %a, %b
+ %x = call i32 @foo (i32 %a) readnone
+ %y = call i32 @foo (i32 %c) readnone
+ %z = icmp eq i32 %x, %y
+ ret i1 %z
+; CHECK: ret i1 true
+}
diff --git a/test/Transforms/GVN/calls-nonlocal.ll b/test/Transforms/GVN/calls-nonlocal.ll
index f0edf09bff988..24ef2e9ec4121 100644
--- a/test/Transforms/GVN/calls-nonlocal.ll
+++ b/test/Transforms/GVN/calls-nonlocal.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | grep strlen | count 2
+; RUN: opt < %s -basicaa -gvn -S | grep strlen | count 2
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i386-apple-darwin9"
diff --git a/test/Transforms/GVN/condprop.ll b/test/Transforms/GVN/condprop.ll
index e212d791ae5a9..be6c3498fe409 100644
--- a/test/Transforms/GVN/condprop.ll
+++ b/test/Transforms/GVN/condprop.ll
@@ -1,52 +1,55 @@
-; RUN: opt < %s -gvn -S | grep {br i1 false}
+; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
@a = external global i32 ; <i32*> [#uses=7]
+; CHECK: @foo
define i32 @foo() nounwind {
entry:
- %0 = load i32* @a, align 4 ; <i32> [#uses=1]
- %1 = icmp eq i32 %0, 4 ; <i1> [#uses=1]
+ %0 = load i32* @a, align 4
+ %1 = icmp eq i32 %0, 4
br i1 %1, label %bb, label %bb1
bb: ; preds = %entry
br label %bb8
bb1: ; preds = %entry
- %2 = load i32* @a, align 4 ; <i32> [#uses=1]
- %3 = icmp eq i32 %2, 5 ; <i1> [#uses=1]
+ %2 = load i32* @a, align 4
+ %3 = icmp eq i32 %2, 5
br i1 %3, label %bb2, label %bb3
bb2: ; preds = %bb1
br label %bb8
bb3: ; preds = %bb1
- %4 = load i32* @a, align 4 ; <i32> [#uses=1]
- %5 = icmp eq i32 %4, 4 ; <i1> [#uses=1]
+ %4 = load i32* @a, align 4
+ %5 = icmp eq i32 %4, 4
+; CHECK: br i1 false, label %bb4, label %bb5
br i1 %5, label %bb4, label %bb5
bb4: ; preds = %bb3
- %6 = load i32* @a, align 4 ; <i32> [#uses=1]
- %7 = add i32 %6, 5 ; <i32> [#uses=1]
+ %6 = load i32* @a, align 4
+ %7 = add i32 %6, 5
br label %bb8
bb5: ; preds = %bb3
- %8 = load i32* @a, align 4 ; <i32> [#uses=1]
- %9 = icmp eq i32 %8, 5 ; <i1> [#uses=1]
+ %8 = load i32* @a, align 4
+ %9 = icmp eq i32 %8, 5
+; CHECK: br i1 false, label %bb6, label %bb7
br i1 %9, label %bb6, label %bb7
bb6: ; preds = %bb5
- %10 = load i32* @a, align 4 ; <i32> [#uses=1]
- %11 = add i32 %10, 4 ; <i32> [#uses=1]
+ %10 = load i32* @a, align 4
+ %11 = add i32 %10, 4
br label %bb8
bb7: ; preds = %bb5
- %12 = load i32* @a, align 4 ; <i32> [#uses=1]
+ %12 = load i32* @a, align 4
br label %bb8
bb8: ; preds = %bb7, %bb6, %bb4, %bb2, %bb
- %.0 = phi i32 [ %12, %bb7 ], [ %11, %bb6 ], [ %7, %bb4 ], [ 4, %bb2 ], [ 5, %bb ] ; <i32> [#uses=1]
+ %.0 = phi i32 [ %12, %bb7 ], [ %11, %bb6 ], [ %7, %bb4 ], [ 4, %bb2 ], [ 5, %bb ]
br label %return
return: ; preds = %bb8
ret i32 %.0
-}
+} \ No newline at end of file
diff --git a/test/Transforms/GVN/invariant-simple.ll b/test/Transforms/GVN/invariant-simple.ll
index 0a4182c410aeb..98ea48cdde324 100644
--- a/test/Transforms/GVN/invariant-simple.ll
+++ b/test/Transforms/GVN/invariant-simple.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | FileCheck %s
+; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i386-apple-darwin7"
diff --git a/test/Transforms/GVN/lifetime-simple.ll b/test/Transforms/GVN/lifetime-simple.ll
index 48e5bc8bb63fb..02f7bcc9e8570 100644
--- a/test/Transforms/GVN/lifetime-simple.ll
+++ b/test/Transforms/GVN/lifetime-simple.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | FileCheck %s
+; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i386-apple-darwin7"
diff --git a/test/Transforms/GVN/load-constant-mem.ll b/test/Transforms/GVN/load-constant-mem.ll
index 87f33eaadadb1..314c8069cacef 100644
--- a/test/Transforms/GVN/load-constant-mem.ll
+++ b/test/Transforms/GVN/load-constant-mem.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -instcombine -S | grep {ret i32 0}
+; RUN: opt < %s -basicaa -gvn -instcombine -S | grep {ret i32 0}
; PR4189
@G = external constant [4 x i32]
diff --git a/test/Transforms/GVN/load-pre-licm.ll b/test/Transforms/GVN/load-pre-licm.ll
new file mode 100644
index 0000000000000..63541ad181d1d
--- /dev/null
+++ b/test/Transforms/GVN/load-pre-licm.ll
@@ -0,0 +1,39 @@
+; RUN: opt -S -basicaa -gvn < %s | FileCheck %s
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
+target triple = "i386-apple-darwin11.0.0"
+
+@sortlist = external global [5001 x i32], align 4
+
+define void @Bubble() nounwind noinline {
+; CHECK: entry:
+; CHECK-NEXT: %tmp7.pre = load i32
+entry:
+ br label %while.body5
+
+; CHECK: while.body5:
+; CHECK: %tmp7 = phi i32
+; CHECK-NOT: %tmp7 = load i32
+while.body5:
+ %indvar = phi i32 [ 0, %entry ], [ %tmp6, %if.end ]
+ %tmp5 = add i32 %indvar, 2
+ %arrayidx9 = getelementptr [5001 x i32]* @sortlist, i32 0, i32 %tmp5
+ %tmp6 = add i32 %indvar, 1
+ %arrayidx = getelementptr [5001 x i32]* @sortlist, i32 0, i32 %tmp6
+ %tmp7 = load i32* %arrayidx, align 4
+ %tmp10 = load i32* %arrayidx9, align 4
+ %cmp11 = icmp sgt i32 %tmp7, %tmp10
+ br i1 %cmp11, label %if.then, label %if.end
+
+; CHECK: if.then:
+if.then:
+ store i32 %tmp10, i32* %arrayidx, align 4
+ store i32 %tmp7, i32* %arrayidx9, align 4
+ br label %if.end
+
+if.end:
+ %exitcond = icmp eq i32 %tmp6, 100
+ br i1 %exitcond, label %while.end.loopexit, label %while.body5
+
+while.end.loopexit:
+ ret void
+}
diff --git a/test/Transforms/GVN/lpre-call-wrap-2.ll b/test/Transforms/GVN/lpre-call-wrap-2.ll
index 79512a33d9930..e39f3ed87d1c3 100644
--- a/test/Transforms/GVN/lpre-call-wrap-2.ll
+++ b/test/Transforms/GVN/lpre-call-wrap-2.ll
@@ -1,4 +1,4 @@
-; RUN: opt -S -gvn -enable-load-pre %s | FileCheck %s
+; RUN: opt -S -basicaa -gvn -enable-load-pre %s | FileCheck %s
;
; The partially redundant load in bb1 should be hoisted to "bb". This comes
; from this C code (GCC PR 23455):
diff --git a/test/Transforms/GVN/mixed.ll b/test/Transforms/GVN/mixed.ll
index 5152f68f0efb5..6bfada2f4d5c2 100644
--- a/test/Transforms/GVN/mixed.ll
+++ b/test/Transforms/GVN/mixed.ll
@@ -1,5 +1,5 @@
-; RUN: opt < %s -gvn -S | not grep DEADLOAD
-; RUN: opt < %s -gvn -S | not grep DEADGEP
+; RUN: opt < %s -basicaa -gvn -S | not grep DEADLOAD
+; RUN: opt < %s -basicaa -gvn -S | not grep DEADGEP
define i32 @main(i32** %p) {
block1:
diff --git a/test/Transforms/GVN/non-local-offset.ll b/test/Transforms/GVN/non-local-offset.ll
new file mode 100644
index 0000000000000..8eaa99933ab9f
--- /dev/null
+++ b/test/Transforms/GVN/non-local-offset.ll
@@ -0,0 +1,59 @@
+; RUN: opt -basicaa -gvn -S < %s | FileCheck %s
+
+target datalayout = "e-p:64:64:64"
+
+; GVN should ignore the store to p[1] to see that the load from p[0] is
+; fully redundant.
+
+; CHECK: @yes
+; CHECK: if.then:
+; CHECK-NEXT: store i32 0, i32* %q
+; CHECK-NEXT: ret void
+
+define void @yes(i1 %c, i32* %p, i32* %q) nounwind {
+entry:
+ store i32 0, i32* %p
+ %p1 = getelementptr inbounds i32* %p, i64 1
+ store i32 1, i32* %p1
+ br i1 %c, label %if.else, label %if.then
+
+if.then:
+ %t = load i32* %p
+ store i32 %t, i32* %q
+ ret void
+
+if.else:
+ ret void
+}
+
+; GVN should ignore the store to p[1] to see that the first load from p[0] is
+; fully redundant. However, the second load is larger, so it's not a simple
+; redundancy.
+
+; CHECK: @watch_out_for_size_change
+; CHECK: if.then:
+; CHECK-NEXT: store i32 0, i32* %q
+; CHECK-NEXT: ret void
+; CHECK: if.else:
+; CHECK: load i64* %pc
+; CHECK: store i64
+
+define void @watch_out_for_size_change(i1 %c, i32* %p, i32* %q) nounwind {
+entry:
+ store i32 0, i32* %p
+ %p1 = getelementptr inbounds i32* %p, i64 1
+ store i32 1, i32* %p1
+ br i1 %c, label %if.else, label %if.then
+
+if.then:
+ %t = load i32* %p
+ store i32 %t, i32* %q
+ ret void
+
+if.else:
+ %pc = bitcast i32* %p to i64*
+ %qc = bitcast i32* %q to i64*
+ %t64 = load i64* %pc
+ store i64 %t64, i64* %qc
+ ret void
+}
diff --git a/test/Transforms/GVN/nonescaping-malloc.ll b/test/Transforms/GVN/nonescaping-malloc.ll
index 5a42d9536ca1e..1d50205c6851b 100644
--- a/test/Transforms/GVN/nonescaping-malloc.ll
+++ b/test/Transforms/GVN/nonescaping-malloc.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -stats -disable-output |& grep {Number of loads deleted}
+; RUN: opt < %s -basicaa -gvn -stats -disable-output |& grep {Number of loads deleted}
; rdar://7363102
; GVN should be able to eliminate load %tmp22.i, because it is redundant with
diff --git a/test/Transforms/GVN/null-aliases-nothing.ll b/test/Transforms/GVN/null-aliases-nothing.ll
index 4d533bbc40643..9e4ae18c710cc 100644
--- a/test/Transforms/GVN/null-aliases-nothing.ll
+++ b/test/Transforms/GVN/null-aliases-nothing.ll
@@ -1,4 +1,4 @@
-; RUN: opt %s -gvn -S | FileCheck %s
+; RUN: opt %s -basicaa -gvn -S | FileCheck %s
%t = type { i32 }
declare void @test1f(i8*)
diff --git a/test/Transforms/GVN/phi-translate.ll b/test/Transforms/GVN/phi-translate.ll
new file mode 100644
index 0000000000000..f10537e0c9300
--- /dev/null
+++ b/test/Transforms/GVN/phi-translate.ll
@@ -0,0 +1,31 @@
+; RUN: opt -basicaa -gvn -S < %s | FileCheck %s
+
+target datalayout = "e-p:64:64:64"
+
+; CHECK: @foo
+; CHECK: entry.end_crit_edge:
+; CHECK: %n.pre = load i32* %q.phi.trans.insert
+; CHECK: then:
+; CHECK: store i32 %z
+; CHECK: end:
+; CHECK: %n = phi i32 [ %n.pre, %entry.end_crit_edge ], [ %z, %then ]
+; CHECK: ret i32 %n
+
+@G = external global [100 x i32]
+define i32 @foo(i32 %x, i32 %z) {
+entry:
+ %tobool = icmp eq i32 %x, 0
+ br i1 %tobool, label %end, label %then
+
+then:
+ %i = sext i32 %x to i64
+ %p = getelementptr [100 x i32]* @G, i64 0, i64 %i
+ store i32 %z, i32* %p
+ br label %end
+
+end:
+ %j = sext i32 %x to i64
+ %q = getelementptr [100 x i32]* @G, i64 0, i64 %j
+ %n = load i32* %q
+ ret i32 %n
+}
diff --git a/test/Transforms/GVN/pre-load.ll b/test/Transforms/GVN/pre-load.ll
index d40a467bf6776..bf4add42e80b6 100644
--- a/test/Transforms/GVN/pre-load.ll
+++ b/test/Transforms/GVN/pre-load.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -enable-load-pre -S | FileCheck %s
+; RUN: opt < %s -basicaa -gvn -enable-load-pre -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"
define i32 @test1(i32* %p, i1 %C) {
diff --git a/test/Transforms/GVN/pre-single-pred.ll b/test/Transforms/GVN/pre-single-pred.ll
index 706a16b7bdd28..f1f5c71a93ab8 100644
--- a/test/Transforms/GVN/pre-single-pred.ll
+++ b/test/Transforms/GVN/pre-single-pred.ll
@@ -1,4 +1,13 @@
-; RUN: opt < %s -gvn -enable-load-pre -S | not grep {tmp3 = load}
+; RUN: opt < %s -gvn -enable-load-pre -S | FileCheck %s
+; This testcase assumed we'll PRE the load into %for.cond, but we don't actually
+; verify that doing so is safe. If there didn't _happen_ to be a load in
+; %for.end, we would actually be lengthening the execution on some paths, and
+; we were never actually checking that case. Now we actually do perform some
+; conservative checking to make sure we don't make paths longer, but we don't
+; currently get this case, which we got lucky on previously.
+;
+; Now that that faulty assumption is corrected, test that we DON'T incorrectly
+; hoist the load. Doing the right thing for the wrong reasons is still a bug.
@p = external global i32
define i32 @f(i32 %n) nounwind {
@@ -13,6 +22,8 @@ for.cond: ; preds = %for.inc, %entry
for.cond.for.end_crit_edge: ; preds = %for.cond
br label %for.end
+; CHECK: for.body:
+; CHECK-NEXT: %tmp3 = load i32* @p
for.body: ; preds = %for.cond
%tmp3 = load i32* @p ; <i32> [#uses=1]
%dec = add i32 %tmp3, -1 ; <i32> [#uses=2]
@@ -20,6 +31,7 @@ for.body: ; preds = %for.cond
%cmp6 = icmp slt i32 %dec, 0 ; <i1> [#uses=1]
br i1 %cmp6, label %for.body.for.end_crit_edge, label %for.inc
+; CHECK: for.body.for.end_crit_edge:
for.body.for.end_crit_edge: ; preds = %for.body
br label %for.end
diff --git a/test/Transforms/GVN/preserve-tbaa.ll b/test/Transforms/GVN/preserve-tbaa.ll
new file mode 100644
index 0000000000000..2fcfc471c5d2b
--- /dev/null
+++ b/test/Transforms/GVN/preserve-tbaa.ll
@@ -0,0 +1,28 @@
+; RUN: opt -tbaa -basicaa -gvn -S < %s | FileCheck %s
+
+target datalayout = "e-p:64:64:64"
+
+; GVN should preserve the TBAA tag on loads when doing PRE.
+
+; CHECK: @test
+; CHECK: %tmp33.pre = load i16* undef, align 2, !tbaa !0
+; CHECK: br label %for.body
+define void @test() nounwind {
+entry:
+ br i1 undef, label %bb.nph, label %for.end
+
+bb.nph: ; preds = %entry
+ br label %for.body
+
+for.body: ; preds = %for.body, %bb.nph
+ %tmp33 = load i16* undef, align 2, !tbaa !0
+ store i16 undef, i16* undef, align 2, !tbaa !0
+ br i1 false, label %for.end, label %for.body
+
+for.end: ; preds = %for.body, %entry
+ ret void
+}
+
+!0 = metadata !{metadata !"short", metadata !1}
+!1 = metadata !{metadata !"omnipotent char", metadata !2}
+!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
diff --git a/test/Transforms/GVN/rle-must-alias.ll b/test/Transforms/GVN/rle-must-alias.ll
index d61eb81b06914..479724063e0b3 100644
--- a/test/Transforms/GVN/rle-must-alias.ll
+++ b/test/Transforms/GVN/rle-must-alias.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | grep {DEAD = phi i32 }
+; RUN: opt < %s -basicaa -gvn -S | grep {DEAD = phi i32 }
; GVN should eliminate the fully redundant %9 GEP which
; allows DEAD to be removed. This is PR3198.
diff --git a/test/Transforms/GVN/rle-nonlocal.ll b/test/Transforms/GVN/rle-nonlocal.ll
index 5c73dad399e69..6b74e9a946d16 100644
--- a/test/Transforms/GVN/rle-nonlocal.ll
+++ b/test/Transforms/GVN/rle-nonlocal.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | FileCheck %s
+; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
define i32 @main(i32** %p) {
block1:
diff --git a/test/Transforms/GVN/rle-semidominated.ll b/test/Transforms/GVN/rle-semidominated.ll
index 04e8c38568457..c6cd1fdc00c53 100644
--- a/test/Transforms/GVN/rle-semidominated.ll
+++ b/test/Transforms/GVN/rle-semidominated.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | grep {DEAD = phi i32 }
+; RUN: opt < %s -basicaa -gvn -S | grep {DEAD = phi i32 }
define i32 @main(i32* %p) {
block1:
diff --git a/test/Transforms/GVN/rle.ll b/test/Transforms/GVN/rle.ll
index d656c1a5fcc74..2e43321750706 100644
--- a/test/Transforms/GVN/rle.ll
+++ b/test/Transforms/GVN/rle.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | FileCheck %s
+; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
; 32-bit little endian target.
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"