From e170c76ccdcf9b0343d2d5a2805010ff77b8b56e Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Fri, 24 Feb 2012 15:16:31 +0000 Subject: Teach GVN that x+y is the same as y+x and that xx. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151365 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/GVN/commute.ll | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/Transforms/GVN/commute.ll (limited to 'test/Transforms/GVN') 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 +} -- cgit v1.2.3