summaryrefslogtreecommitdiffstats
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-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/2012-05-22-PreCrash.ll33
-rw-r--r--test/Transforms/GVN/basic.ll2
-rw-r--r--test/Transforms/GVN/calls-readonly.ll2
-rw-r--r--test/Transforms/GVN/fpmath.ll45
-rw-r--r--test/Transforms/GVN/load-constant-mem.ll2
-rw-r--r--test/Transforms/GVN/local-pre.ll2
-rw-r--r--test/Transforms/GVN/nonescaping-malloc.ll2
-rw-r--r--test/Transforms/GVN/pr12979.ll79
-rw-r--r--test/Transforms/GVN/pre-basic-add.ll2
-rw-r--r--test/Transforms/GVN/range.ll101
-rw-r--r--test/Transforms/GVN/rle-must-alias.ll2
-rw-r--r--test/Transforms/GVN/rle-semidominated.ll2
-rw-r--r--test/Transforms/GVN/tbaa.ll81
17 files changed, 351 insertions, 12 deletions
diff --git a/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll b/test/Transforms/GVN/2007-07-25-InfiniteLoop.ll
index 9983374..7e9c982 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 -basicaa -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-31-NoDomInherit.ll b/test/Transforms/GVN/2007-07-31-NoDomInherit.ll
index f2c0012..5018a07 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 -basicaa -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 a570e35..13419d1 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 -basicaa -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 407940b..4f07868 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 -basicaa -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/2012-05-22-PreCrash.ll b/test/Transforms/GVN/2012-05-22-PreCrash.ll
new file mode 100644
index 0000000..b488dda
--- /dev/null
+++ b/test/Transforms/GVN/2012-05-22-PreCrash.ll
@@ -0,0 +1,33 @@
+; RUN: opt < %s -gvn
+; PR12858
+
+define void @fn5(i16 signext %p1, i8 signext %p2) nounwind uwtable {
+entry:
+ br i1 undef, label %if.else, label %if.then
+
+if.then: ; preds = %entry
+ br label %if.end
+
+if.else: ; preds = %entry
+ %conv = sext i16 %p1 to i32
+ br label %if.end
+
+if.end: ; preds = %if.else, %if.then
+ %conv1 = sext i16 %p1 to i32
+ br i1 undef, label %if.then3, label %if.else4
+
+if.then3: ; preds = %if.end
+ br label %if.end12
+
+if.else4: ; preds = %if.end
+ %conv7 = sext i8 %p2 to i32
+ %cmp8 = icmp eq i32 %conv1, %conv7
+ br i1 %cmp8, label %if.then10, label %if.end12
+
+if.then10: ; preds = %if.else4
+ br label %if.end12
+
+if.end12: ; preds = %if.then10, %if.else4, %if.then3
+ %conv13 = sext i8 %p2 to i32
+ ret void
+}
diff --git a/test/Transforms/GVN/basic.ll b/test/Transforms/GVN/basic.ll
index 1decafa..6f4aace 100644
--- a/test/Transforms/GVN/basic.ll
+++ b/test/Transforms/GVN/basic.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -S | not grep {%z2 =}
+; RUN: opt < %s -gvn -S | not grep "%z2 ="
define i32 @main() {
block1:
diff --git a/test/Transforms/GVN/calls-readonly.ll b/test/Transforms/GVN/calls-readonly.ll
index 97ec915..a477740 100644
--- a/test/Transforms/GVN/calls-readonly.ll
+++ b/test/Transforms/GVN/calls-readonly.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -basicaa -gvn -S | grep {call.*strlen} | count 1
+; RUN: opt < %s -basicaa -gvn -S | grep "call.*strlen" | count 1
; Should delete the second call to strlen even though the intervening strchr call exists.
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"
diff --git a/test/Transforms/GVN/fpmath.ll b/test/Transforms/GVN/fpmath.ll
new file mode 100644
index 0000000..8ab2854
--- /dev/null
+++ b/test/Transforms/GVN/fpmath.ll
@@ -0,0 +1,45 @@
+; RUN: opt %s -gvn -S -o - | FileCheck %s
+
+define double @test1(double %x, double %y) {
+; CHECK: @test1(double %x, double %y)
+; CHECK: %add1 = fadd double %x, %y
+; CHECK-NOT: fpmath
+; CHECK: %foo = fadd double %add1, %add1
+ %add1 = fadd double %x, %y, !fpmath !0
+ %add2 = fadd double %x, %y
+ %foo = fadd double %add1, %add2
+ ret double %foo
+}
+
+define double @test2(double %x, double %y) {
+; CHECK: @test2(double %x, double %y)
+; CHECK: %add1 = fadd double %x, %y, !fpmath !0
+; CHECK: %foo = fadd double %add1, %add1
+ %add1 = fadd double %x, %y, !fpmath !0
+ %add2 = fadd double %x, %y, !fpmath !0
+ %foo = fadd double %add1, %add2
+ ret double %foo
+}
+
+define double @test3(double %x, double %y) {
+; CHECK: @test3(double %x, double %y)
+; CHECK: %add1 = fadd double %x, %y, !fpmath !1
+; CHECK: %foo = fadd double %add1, %add1
+ %add1 = fadd double %x, %y, !fpmath !1
+ %add2 = fadd double %x, %y, !fpmath !0
+ %foo = fadd double %add1, %add2
+ ret double %foo
+}
+
+define double @test4(double %x, double %y) {
+; CHECK: @test4(double %x, double %y)
+; CHECK: %add1 = fadd double %x, %y, !fpmath !1
+; CHECK: %foo = fadd double %add1, %add1
+ %add1 = fadd double %x, %y, !fpmath !0
+ %add2 = fadd double %x, %y, !fpmath !1
+ %foo = fadd double %add1, %add2
+ ret double %foo
+}
+
+!0 = metadata !{ float 5.0 }
+!1 = metadata !{ float 2.5 }
diff --git a/test/Transforms/GVN/load-constant-mem.ll b/test/Transforms/GVN/load-constant-mem.ll
index 314c806..a7dacea 100644
--- a/test/Transforms/GVN/load-constant-mem.ll
+++ b/test/Transforms/GVN/load-constant-mem.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -basicaa -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/local-pre.ll b/test/Transforms/GVN/local-pre.ll
index 5f03984..1d0dadf 100644
--- a/test/Transforms/GVN/local-pre.ll
+++ b/test/Transforms/GVN/local-pre.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -enable-pre -S | grep {b.pre}
+; RUN: opt < %s -gvn -enable-pre -S | grep "b.pre"
define i32 @main(i32 %p) {
block1:
diff --git a/test/Transforms/GVN/nonescaping-malloc.ll b/test/Transforms/GVN/nonescaping-malloc.ll
index dba9d81..afcb7fe 100644
--- a/test/Transforms/GVN/nonescaping-malloc.ll
+++ b/test/Transforms/GVN/nonescaping-malloc.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -basicaa -gvn -stats -disable-output |& grep {Number of loads deleted}
+; RUN: opt < %s -basicaa -gvn -stats -disable-output 2>&1 | 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/pr12979.ll b/test/Transforms/GVN/pr12979.ll
new file mode 100644
index 0000000..669da91
--- /dev/null
+++ b/test/Transforms/GVN/pr12979.ll
@@ -0,0 +1,79 @@
+; RUN: opt %s -gvn -S -o - | FileCheck %s
+
+define i32 @test1(i32 %x, i32 %y) {
+; CHECK: @test1(i32 %x, i32 %y)
+; CHECK: %add1 = add i32 %x, %y
+; CHECK: %foo = add i32 %add1, %add1
+
+ %add1 = add nsw i32 %x, %y
+ %add2 = add i32 %x, %y
+ %foo = add i32 %add1, %add2
+ ret i32 %foo
+}
+
+define i32 @test2(i32 %x, i32 %y) {
+; CHECK: @test2(i32 %x, i32 %y)
+; CHECK: %add1 = add i32 %x, %y
+; CHECK: %foo = add i32 %add1, %add1
+
+ %add1 = add nuw i32 %x, %y
+ %add2 = add i32 %x, %y
+ %foo = add i32 %add1, %add2
+ ret i32 %foo
+}
+
+define i32 @test3(i32 %x, i32 %y) {
+; CHECK: @test3(i32 %x, i32 %y)
+; CHECK: %add1 = add i32 %x, %y
+; CHECK: %foo = add i32 %add1, %add1
+
+ %add1 = add nuw nsw i32 %x, %y
+ %add2 = add i32 %x, %y
+ %foo = add i32 %add1, %add2
+ ret i32 %foo
+}
+
+define i32 @test4(i32 %x, i32 %y) {
+; CHECK: @test4(i32 %x, i32 %y)
+; CHECK: %add1 = add nsw i32 %x, %y
+; CHECK: %foo = add i32 %add1, %add1
+
+ %add1 = add nsw i32 %x, %y
+ %add2 = add nsw i32 %x, %y
+ %foo = add i32 %add1, %add2
+ ret i32 %foo
+}
+
+define i32 @test5(i32 %x, i32 %y) {
+; CHECK: @test5(i32 %x, i32 %y)
+; CHECK: %add1 = add i32 %x, %y
+; CHECK: %foo = add i32 %add1, %add1
+
+ %add1 = add nuw i32 %x, %y
+ %add2 = add nsw i32 %x, %y
+ %foo = add i32 %add1, %add2
+ ret i32 %foo
+}
+
+define i32 @test6(i32 %x, i32 %y) {
+; CHECK: @test6(i32 %x, i32 %y)
+; CHECK: %add1 = add nsw i32 %x, %y
+; CHECK: %foo = add i32 %add1, %add1
+
+ %add1 = add nuw nsw i32 %x, %y
+ %add2 = add nsw i32 %x, %y
+ %foo = add i32 %add1, %add2
+ ret i32 %foo
+}
+
+define i32 @test7(i32 %x, i32 %y) {
+; CHECK: @test7(i32 %x, i32 %y)
+; CHECK: %add1 = add i32 %x, %y
+; CHECK-NOT: what_is_this
+; CHECK: %foo = add i32 %add1, %add1
+
+ %add1 = add i32 %x, %y, !what_is_this !{}
+ %add2 = add i32 %x, %y
+ %foo = add i32 %add1, %add2
+ ret i32 %foo
+}
diff --git a/test/Transforms/GVN/pre-basic-add.ll b/test/Transforms/GVN/pre-basic-add.ll
index c13099f..4bde05c 100644
--- a/test/Transforms/GVN/pre-basic-add.ll
+++ b/test/Transforms/GVN/pre-basic-add.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -gvn -enable-pre -S | grep {.pre}
+; RUN: opt < %s -gvn -enable-pre -S | grep ".pre"
@H = common global i32 0 ; <i32*> [#uses=2]
@G = common global i32 0 ; <i32*> [#uses=1]
diff --git a/test/Transforms/GVN/range.ll b/test/Transforms/GVN/range.ll
new file mode 100644
index 0000000..3759c41
--- /dev/null
+++ b/test/Transforms/GVN/range.ll
@@ -0,0 +1,101 @@
+; RUN: opt %s -basicaa -gvn -S -o - | FileCheck %s
+
+define i32 @test1(i32* %p) {
+; CHECK: @test1(i32* %p)
+; CHECK: %a = load i32* %p, !range !0
+; CHECK: %c = add i32 %a, %a
+ %a = load i32* %p, !range !0
+ %b = load i32* %p, !range !0
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test2(i32* %p) {
+; CHECK: @test2(i32* %p)
+; CHECK: %a = load i32* %p
+; CHECK-NOT: range
+; CHECK: %c = add i32 %a, %a
+ %a = load i32* %p, !range !0
+ %b = load i32* %p
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test3(i32* %p) {
+; CHECK: @test3(i32* %p)
+; CHECK: %a = load i32* %p, !range ![[DISJOINT_RANGE:[0-9]+]]
+; CHECK: %c = add i32 %a, %a
+ %a = load i32* %p, !range !0
+ %b = load i32* %p, !range !1
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test4(i32* %p) {
+; CHECK: @test4(i32* %p)
+; CHECK: %a = load i32* %p, !range ![[MERGED_RANGE:[0-9]+]]
+; CHECK: %c = add i32 %a, %a
+ %a = load i32* %p, !range !0
+ %b = load i32* %p, !range !2
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test5(i32* %p) {
+; CHECK: @test5(i32* %p)
+; CHECK: %a = load i32* %p, !range ![[MERGED_SIGNED_RANGE:[0-9]+]]
+; CHECK: %c = add i32 %a, %a
+ %a = load i32* %p, !range !3
+ %b = load i32* %p, !range !4
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test6(i32* %p) {
+; CHECK: @test6(i32* %p)
+; CHECK: %a = load i32* %p, !range ![[MERGED_TEST6:[0-9]+]]
+; CHECK: %c = add i32 %a, %a
+ %a = load i32* %p, !range !5
+ %b = load i32* %p, !range !6
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test7(i32* %p) {
+; CHECK: @test7(i32* %p)
+; CHECK: %a = load i32* %p, !range ![[MERGED_TEST7:[0-9]+]]
+; CHECK: %c = add i32 %a, %a
+ %a = load i32* %p, !range !7
+ %b = load i32* %p, !range !8
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test8(i32* %p) {
+; CHECK: @test8(i32* %p)
+; CHECK: %a = load i32* %p
+; CHECK-NOT: range
+; CHECK: %c = add i32 %a, %a
+ %a = load i32* %p, !range !9
+ %b = load i32* %p, !range !10
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+; CHECK: ![[DISJOINT_RANGE]] = metadata !{i32 0, i32 2, i32 3, i32 5}
+; CHECK: ![[MERGED_RANGE]] = metadata !{i32 0, i32 5}
+; CHECK: ![[MERGED_SIGNED_RANGE]] = metadata !{i32 -3, i32 -2, i32 1, i32 2}
+; CHECK: ![[MERGED_TEST6]] = metadata !{i32 10, i32 1}
+; CHECK: ![[MERGED_TEST7]] = metadata !{i32 3, i32 4, i32 5, i32 2}
+
+!0 = metadata !{i32 0, i32 2}
+!1 = metadata !{i32 3, i32 5}
+!2 = metadata !{i32 2, i32 5}
+!3 = metadata !{i32 -3, i32 -2}
+!4 = metadata !{i32 1, i32 2}
+!5 = metadata !{i32 10, i32 1}
+!6 = metadata !{i32 12, i32 13}
+!7 = metadata !{i32 1, i32 2, i32 3, i32 4}
+!8 = metadata !{i32 5, i32 1}
+!9 = metadata !{i32 1, i32 5}
+!10 = metadata !{i32 5, i32 1}
diff --git a/test/Transforms/GVN/rle-must-alias.ll b/test/Transforms/GVN/rle-must-alias.ll
index 4797240..e7dc9c4 100644
--- a/test/Transforms/GVN/rle-must-alias.ll
+++ b/test/Transforms/GVN/rle-must-alias.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -basicaa -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-semidominated.ll b/test/Transforms/GVN/rle-semidominated.ll
index c6cd1fd..71aa548 100644
--- a/test/Transforms/GVN/rle-semidominated.ll
+++ b/test/Transforms/GVN/rle-semidominated.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -basicaa -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/tbaa.ll b/test/Transforms/GVN/tbaa.ll
new file mode 100644
index 0000000..90661c6
--- /dev/null
+++ b/test/Transforms/GVN/tbaa.ll
@@ -0,0 +1,81 @@
+; RUN: opt %s -basicaa -gvn -S -o - | FileCheck %s
+
+define i32 @test1(i8* %p, i8* %q) {
+; CHECK: @test1(i8* %p, i8* %q)
+; CHECK: call i32 @foo(i8* %p)
+; CHECK-NOT: tbaa
+; CHECK: %c = add i32 %a, %a
+ %a = call i32 @foo(i8* %p), !tbaa !0
+ %b = call i32 @foo(i8* %p)
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test2(i8* %p, i8* %q) {
+; CHECK: @test2(i8* %p, i8* %q)
+; CHECK: call i32 @foo(i8* %p), !tbaa !0
+; CHECK: %c = add i32 %a, %a
+ %a = call i32 @foo(i8* %p), !tbaa !0
+ %b = call i32 @foo(i8* %p), !tbaa !0
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test3(i8* %p, i8* %q) {
+; CHECK: @test3(i8* %p, i8* %q)
+; CHECK: call i32 @foo(i8* %p), !tbaa !3
+; CHECK: %c = add i32 %a, %a
+ %a = call i32 @foo(i8* %p), !tbaa !3
+ %b = call i32 @foo(i8* %p), !tbaa !3
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test4(i8* %p, i8* %q) {
+; CHECK: @test4(i8* %p, i8* %q)
+; CHECK: call i32 @foo(i8* %p), !tbaa !1
+; CHECK: %c = add i32 %a, %a
+ %a = call i32 @foo(i8* %p), !tbaa !1
+ %b = call i32 @foo(i8* %p), !tbaa !0
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test5(i8* %p, i8* %q) {
+; CHECK: @test5(i8* %p, i8* %q)
+; CHECK: call i32 @foo(i8* %p), !tbaa !1
+; CHECK: %c = add i32 %a, %a
+ %a = call i32 @foo(i8* %p), !tbaa !0
+ %b = call i32 @foo(i8* %p), !tbaa !1
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test6(i8* %p, i8* %q) {
+; CHECK: @test6(i8* %p, i8* %q)
+; CHECK: call i32 @foo(i8* %p), !tbaa !1
+; CHECK: %c = add i32 %a, %a
+ %a = call i32 @foo(i8* %p), !tbaa !0
+ %b = call i32 @foo(i8* %p), !tbaa !3
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+define i32 @test7(i8* %p, i8* %q) {
+; CHECK: @test7(i8* %p, i8* %q)
+; CHECK: call i32 @foo(i8* %p)
+; CHECK-NOT: tbaa
+; CHECK: %c = add i32 %a, %a
+ %a = call i32 @foo(i8* %p), !tbaa !4
+ %b = call i32 @foo(i8* %p), !tbaa !3
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+declare i32 @foo(i8*) readonly
+
+!0 = metadata !{metadata !"C", metadata !1}
+!1 = metadata !{metadata !"A", metadata !2}
+!2 = metadata !{metadata !"tbaa root", null}
+!3 = metadata !{metadata !"B", metadata !1}
+!4 = metadata !{metadata !"another root", null}
OpenPOWER on IntegriCloud