It's not necessary to do rounding for alloca operations when the requested
alignment is equal to the stack alignment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40004 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/LoadVN/RLE-Eliminate.ll b/test/Analysis/LoadVN/RLE-Eliminate.ll
new file mode 100644
index 0000000..4c3a668
--- /dev/null
+++ b/test/Analysis/LoadVN/RLE-Eliminate.ll
@@ -0,0 +1,23 @@
+; This testcase ensures that redundant loads are eliminated when they should 
+; be.  All RL variables (redundant loads) should be eliminated.
+;
+; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse | llvm-dis | not grep %RL
+;
+int "test1"(int* %P) {
+	%A = load int* %P
+	%RL = load int* %P
+	%C = add int %A, %RL
+	ret int %C
+}
+
+int "test2"(int* %P) {
+	%A = load int* %P
+	br label %BB2
+BB2:
+	br label %BB3
+BB3:
+	%RL = load int* %P
+	%B = add int %A, %RL
+	ret int %B
+}
+
diff --git a/test/Analysis/LoadVN/RLE-Preserve-Volatile.ll b/test/Analysis/LoadVN/RLE-Preserve-Volatile.ll
new file mode 100644
index 0000000..9966016
--- /dev/null
+++ b/test/Analysis/LoadVN/RLE-Preserve-Volatile.ll
@@ -0,0 +1,9 @@
+
+; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse -instcombine | llvm-dis | grep sub
+
+int %test(int* %P) {
+	%X = volatile load int* %P
+	%Y = volatile load int* %P
+	%Z = sub int %X, %Y
+	ret int %Z
+}
diff --git a/test/Analysis/LoadVN/RLE-Preserve.ll b/test/Analysis/LoadVN/RLE-Preserve.ll
new file mode 100644
index 0000000..e08c41c
--- /dev/null
+++ b/test/Analysis/LoadVN/RLE-Preserve.ll
@@ -0,0 +1,25 @@
+; This testcase ensures that redundant loads are preserved when they are not 
+; allowed to be eliminated.
+; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse | llvm-dis | grep sub
+;
+int %test1(int* %P) {
+	%A = load int* %P
+	store int 1, int* %P
+	%B = load int* %P
+	%C = sub int %A, %B
+	ret int %C
+}
+
+int %test2(int* %P) {
+	%A = load int* %P
+	br label %BB2
+BB2:
+	store int 5, int* %P
+	br label %BB3
+BB3:
+	%B = load int* %P
+	%C = sub int %A, %B
+	ret int %C
+}
+
+
diff --git a/test/Analysis/LoadVN/call_cse.ll b/test/Analysis/LoadVN/call_cse.ll
new file mode 100644
index 0000000..78cdd43
--- /dev/null
+++ b/test/Analysis/LoadVN/call_cse.ll
@@ -0,0 +1,11 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | not grep sub
+declare int %strlen(sbyte*)
+
+int %test(sbyte* %P) {
+	%X = call int %strlen(sbyte* %P)
+	%A = add int %X, 14
+	%Y = call int %strlen(sbyte* %P)
+	%Z = sub int %X, %Y
+	%B = add int %A, %Z
+	ret int %B
+}
diff --git a/test/Analysis/LoadVN/call_pure_function.ll b/test/Analysis/LoadVN/call_pure_function.ll
new file mode 100644
index 0000000..302ae60
--- /dev/null
+++ b/test/Analysis/LoadVN/call_pure_function.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | not grep sub
+declare int %strlen(sbyte*)
+declare void %use(int %X)
+
+sbyte %test(sbyte* %P, sbyte* %Q) {
+	%A = load sbyte* %Q
+	%X = call int %strlen(sbyte* %P)
+	%B = load sbyte* %Q                ;; CSE with A.
+	call void %use(int %X)             ;; make strlen not dead
+
+	%C = sub sbyte %A, %B
+	ret sbyte %C
+}
diff --git a/test/Analysis/LoadVN/casts.ll b/test/Analysis/LoadVN/casts.ll
new file mode 100644
index 0000000..3da4d57
--- /dev/null
+++ b/test/Analysis/LoadVN/casts.ll
@@ -0,0 +1,13 @@
+; Check to make sure that Value Numbering doesn't merge casts of different
+; flavors.
+; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse | llvm-dis | \
+; RUN:   grep {\[sz\]ext} | wc -l | grep 2
+
+declare void %external(int)
+
+int %test_casts(short %x) {
+  %a = sext short %x to int
+  %b = zext short %x to int
+  call void %external(int %a)
+  ret int %b
+}
diff --git a/test/Analysis/LoadVN/dependent_loads.ll b/test/Analysis/LoadVN/dependent_loads.ll
new file mode 100644
index 0000000..168b640
--- /dev/null
+++ b/test/Analysis/LoadVN/dependent_loads.ll
@@ -0,0 +1,27 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | not grep sub
+
+%S = type { int, sbyte }
+
+sbyte %test(sbyte** %P) {
+	%A = load sbyte** %P
+	%B = load sbyte* %A
+
+	%X = load sbyte** %P
+	%Y = load sbyte* %X
+
+	%R = sub sbyte %B, %Y
+	ret sbyte %R
+}
+
+sbyte %test(%S ** %P) {
+	%A = load %S** %P
+	%B = getelementptr %S* %A, int 0, uint 1
+	%C = load sbyte* %B
+
+	%X = load %S** %P
+	%Y = getelementptr %S* %X, int 0, uint 1
+	%Z = load sbyte* %Y
+
+	%R = sub sbyte %C, %Z
+	ret sbyte %R
+}
diff --git a/test/Analysis/LoadVN/dg.exp b/test/Analysis/LoadVN/dg.exp
new file mode 100644
index 0000000..879685c
--- /dev/null
+++ b/test/Analysis/LoadVN/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]]
diff --git a/test/Analysis/LoadVN/undefined_load.ll b/test/Analysis/LoadVN/undefined_load.ll
new file mode 100644
index 0000000..8e4660c
--- /dev/null
+++ b/test/Analysis/LoadVN/undefined_load.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse | llvm-dis | not grep load
+; Test that loads of undefined memory are eliminated.
+
+int %test1() {
+	%X = malloc int
+	%Y = load int* %X
+	ret int %Y
+}
+int %test2() {
+	%X = alloca int
+	%Y = load int* %X
+	ret int %Y
+}
+