summaryrefslogtreecommitdiff
path: root/test/Transforms/GVN
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2012-02-24 15:16:31 +0000
committerDuncan Sands <baldrick@free.fr>2012-02-24 15:16:31 +0000
commite170c76ccdcf9b0343d2d5a2805010ff77b8b56e (patch)
tree2129356bb19d6704ae20679b6680c6f95ed6a942 /test/Transforms/GVN
parent8b93ff298cbaa8a16f950374e1be1f7e5114da8f (diff)
downloadllvm-e170c76ccdcf9b0343d2d5a2805010ff77b8b56e.tar.gz
llvm-e170c76ccdcf9b0343d2d5a2805010ff77b8b56e.tar.bz2
llvm-e170c76ccdcf9b0343d2d5a2805010ff77b8b56e.tar.xz
Teach GVN that x+y is the same as y+x and that x<y is the same as y>x.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151365 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/GVN')
-rw-r--r--test/Transforms/GVN/commute.ll23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/Transforms/GVN/commute.ll b/test/Transforms/GVN/commute.ll
new file mode 100644
index 0000000000..cf4fb7f172
--- /dev/null
+++ b/test/Transforms/GVN/commute.ll
@@ -0,0 +1,23 @@
+; RUN: opt -gvn -S < %s | FileCheck %s
+
+declare void @use(i32, i32)
+
+define void @foo(i32 %x, i32 %y) {
+ ; CHECK: @foo
+ %add1 = add i32 %x, %y
+ %add2 = add i32 %y, %x
+ call void @use(i32 %add1, i32 %add2)
+ ; CHECK: @use(i32 %add1, i32 %add1)
+ ret void
+}
+
+declare void @vse(i1, i1)
+
+define void @bar(i32 %x, i32 %y) {
+ ; CHECK: @bar
+ %cmp1 = icmp ult i32 %x, %y
+ %cmp2 = icmp ugt i32 %y, %x
+ call void @vse(i1 %cmp1, i1 %cmp2)
+ ; CHECK: @vse(i1 %cmp1, i1 %cmp1)
+ ret void
+}