summaryrefslogtreecommitdiff
path: root/test/Transforms/NewGVN
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/NewGVN')
-rw-r--r--test/Transforms/NewGVN/pr32934.ll69
-rw-r--r--test/Transforms/NewGVN/pr32952.ll42
-rw-r--r--test/Transforms/NewGVN/verify-memoryphi.ll29
3 files changed, 140 insertions, 0 deletions
diff --git a/test/Transforms/NewGVN/pr32934.ll b/test/Transforms/NewGVN/pr32934.ll
new file mode 100644
index 000000000000..4bb7ea150437
--- /dev/null
+++ b/test/Transforms/NewGVN/pr32934.ll
@@ -0,0 +1,69 @@
+; REQUIRES: disabled
+; RUN: opt -S -newgvn %s | FileCheck %s
+
+; CHECK: define void @tinkywinky() {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: %d = alloca i32, align 4
+; CHECK-NEXT: store i32 0, i32* null, align 4
+; CHECK-NEXT: br label %for.cond
+; CHECK: for.cond: ; preds = %if.end, %entry
+; CHECK-NEXT: %0 = load i32, i32* null, align 4
+; CHECK-NEXT: %cmp = icmp slt i32 %0, 1
+; CHECK-NEXT: br i1 %cmp, label %for.body, label %while.cond
+; CHECK: for.body: ; preds = %for.cond
+; CHECK-NEXT: %1 = load i32, i32* @a, align 4
+; CHECK-NEXT: store i32 %1, i32* %d, align 4
+; CHECK-NEXT: br label %L
+; CHECK: L: ; preds = %if.then, %for.body
+; CHECK-NEXT: %tobool = icmp ne i32 %1, 0
+; CHECK-NEXT: br i1 %tobool, label %if.then, label %if.end
+; CHECK: if.then: ; preds = %L
+; CHECK-NEXT: call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @patatino, i32 0, i32 0))
+; CHECK-NEXT: br label %L
+; CHECK: if.end: ; preds = %L
+; CHECK-NEXT: br label %for.cond
+; CHECK: while.cond: ; preds = %while.body, %for.cond
+; CHECK-NEXT: br i1 undef, label %while.body, label %while.end
+; CHECK: while.body: ; preds = %while.cond
+; CHECK-NEXT: call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @patatino, i32 0, i32 0))
+; CHECK-NEXT: br label %while.cond
+; CHECK: while.end:
+; CHECK-NEXT: %2 = load i32, i32* @a, align 4
+; CHECK-NEXT: store i32 %2, i32* undef, align 4
+; CHECK-NEXT: ret void
+
+@a = external global i32, align 4
+@patatino = external unnamed_addr constant [2 x i8], align 1
+define void @tinkywinky() {
+entry:
+ %d = alloca i32, align 4
+ store i32 0, i32* null, align 4
+ br label %for.cond
+for.cond:
+ %0 = load i32, i32* null, align 4
+ %cmp = icmp slt i32 %0, 1
+ br i1 %cmp, label %for.body, label %while.cond
+for.body:
+ %1 = load i32, i32* @a, align 4
+ store i32 %1, i32* %d, align 4
+ br label %L
+L:
+ %2 = load i32, i32* %d, align 4
+ %tobool = icmp ne i32 %2, 0
+ br i1 %tobool, label %if.then, label %if.end
+if.then:
+ call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @patatino, i32 0, i32 0))
+ br label %L
+if.end:
+ br label %for.cond
+while.cond:
+ br i1 undef, label %while.body, label %while.end
+while.body:
+ call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @patatino, i32 0, i32 0))
+ br label %while.cond
+while.end:
+ %3 = load i32, i32* @a, align 4
+ store i32 %3, i32* undef, align 4
+ ret void
+}
+declare void @printf(i8*, ...) #1
diff --git a/test/Transforms/NewGVN/pr32952.ll b/test/Transforms/NewGVN/pr32952.ll
new file mode 100644
index 000000000000..056b3a5105ec
--- /dev/null
+++ b/test/Transforms/NewGVN/pr32952.ll
@@ -0,0 +1,42 @@
+; PR32952: Don't erroneously consider congruent two phi nodes which
+; have the same arguments but different incoming edges.
+; RUN: opt -newgvn -S %s | FileCheck %s
+
+@a = common global i16 0, align 2
+@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
+
+define i32 @tinkywinky() {
+entry:
+ %0 = load i16, i16* @a, align 2
+ %conv = sext i16 %0 to i32
+ %neg = xor i32 %conv, -1
+ %conv1 = trunc i32 %neg to i16
+ %conv3 = zext i16 %conv1 to i32
+ %cmp = icmp slt i32 %conv, %conv3
+ br i1 %cmp, label %tinky, label %winky
+
+tinky:
+ store i16 2, i16* @a, align 2
+ br label %patatino
+
+winky:
+ br label %patatino
+
+patatino:
+; CHECK: %meh = phi i16 [ %0, %winky ], [ %conv1, %tinky ]
+; CHECK: %banana = phi i16 [ %0, %tinky ], [ %conv1, %winky ]
+ %meh = phi i16 [ %0, %winky ], [ %conv1, %tinky ]
+ %banana = phi i16 [ %0, %tinky ], [ %conv1, %winky ]
+ br label %end
+
+end:
+; CHECK: %promoted = zext i16 %banana to i32
+; CHECK: %other = zext i16 %meh to i32
+ %promoted = zext i16 %banana to i32
+ %other = zext i16 %meh to i32
+ %first = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %promoted)
+ %second = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %other)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/Transforms/NewGVN/verify-memoryphi.ll b/test/Transforms/NewGVN/verify-memoryphi.ll
new file mode 100644
index 000000000000..57dbd18986d2
--- /dev/null
+++ b/test/Transforms/NewGVN/verify-memoryphi.ll
@@ -0,0 +1,29 @@
+; Skip dead MemoryPhis when performing memory congruency verification
+; in NewGVN.
+; RUN: opt -S -newgvn %s | FileCheck %s
+; REQUIRES: asserts
+
+; CHECK: define void @tinkywinky() {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 false, label %body, label %end
+; CHECK: body:
+; CHECK-NEXT: store i8 undef, i8* null
+; CHECK-NEXT: br label %end
+; CHECK: end:
+; CHECK-NEXT: ret void
+; CHECK-NEXT: }
+
+declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
+
+define void @tinkywinky() {
+entry:
+ call void @llvm.lifetime.start.p0i8(i64 4, i8* undef)
+ br i1 false, label %body, label %end
+
+body:
+ call void @llvm.lifetime.start.p0i8(i64 4, i8* undef)
+ br label %end
+
+end:
+ ret void
+}