From 05450ae12828337c52f27d68ec9d611dda93c939 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 28 Aug 2006 22:44:55 +0000 Subject: Add PredicateSimplifier pass. Collapses equal variables into one form and simplifies expressions. This implements the optimization described in PR807. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29947 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Transforms/PredicateSimplifier/predsimplify.ll | 130 +++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 test/Transforms/PredicateSimplifier/predsimplify.ll (limited to 'test/Transforms/PredicateSimplifier/predsimplify.ll') diff --git a/test/Transforms/PredicateSimplifier/predsimplify.ll b/test/Transforms/PredicateSimplifier/predsimplify.ll new file mode 100644 index 0000000000..056d8c97dc --- /dev/null +++ b/test/Transforms/PredicateSimplifier/predsimplify.ll @@ -0,0 +1,130 @@ +; RUN: llvm-as < %s | opt -predsimplify -instcombine -simplifycfg | llvm-dis | grep -v declare | not grep fail + +void %test1(int %x) { +entry: + %A = seteq int %x, 0 + br bool %A, label %then.1, label %else.1 +then.1: + %B = seteq int %x, 1 + br bool %B, label %then.2, label %else.1 +then.2: + call void (...)* %fail( ) + ret void +else.1: + ret void +} + +void %test2(int %x) { +entry: + %A = seteq int %x, 0 + %B = seteq int %x, 1 + br bool %A, label %then.1, label %else.1 +then.1: + br bool %B, label %then.2, label %else.1 +then.2: + call void (...)* %fail( ) + ret void +else.1: + ret void +} + +void %test3(int %x) { +entry: + %A = seteq int %x, 0 + %B = seteq int %x, 1 + br bool %A, label %then.1, label %else.1 +then.1: + br bool %B, label %then.2, label %else.1 +then.2: + call void (...)* %fail( ) + ret void +else.1: + ret void +} + +void %test4(int %x, int %y) { +entry: + %A = seteq int %x, 0 + %B = seteq int %y, 0 + %C = and bool %A, %B + br bool %C, label %then.1, label %else.1 +then.1: + %D = seteq int %x, 0 + br bool %D, label %then.2, label %else.2 +then.2: + %E = seteq int %y, 0 + br bool %E, label %else.1, label %else.2 +else.1: + ret void +else.2: + call void (...)* %fail( ) + ret void +} + +void %test5(int %x) { +entry: + %A = seteq int %x, 0 + br bool %A, label %then.1, label %else.1 +then.1: + ret void +then.2: + call void (...)* %fail( ) + ret void +else.1: + %B = seteq int %x, 0 + br bool %B, label %then.2, label %then.1 +} + +void %test6(int %x, int %y) { +entry: + %A = seteq int %x, 0 + %B = seteq int %y, 0 + %C = or bool %A, %B + br bool %C, label %then.1, label %else.1 +then.1: + ret void +then.2: + call void (...)* %fail( ) + ret void +else.1: + %D = seteq int %x, 0 + br bool %D, label %then.2, label %else.2 +else.2: + %E = setne int %y, 0 + br bool %E, label %then.1, label %then.2 +} + +void %test7(int %x) { +entry: + %A = setne int %x, 0 + %B = xor bool %A, true + br bool %B, label %then.1, label %else.1 +then.1: + %C = seteq int %x, 1 + br bool %C, label %then.2, label %else.1 +then.2: + call void (...)* %fail( ) + ret void +else.1: + ret void +} + +void %test8(int %x) { +entry: + %A = add int %x, 1 + %B = seteq int %x, 0 + br bool %B, label %then.1, label %then.2 +then.1: + %C = seteq int %A, 1 + br bool %C, label %then.2, label %else.2 +then.2: + ret void +else.2: + call void (...)* %fail( ) + ret void +} + + +declare void %fail(...) + +declare void %pass(...) -- cgit v1.2.3-18-g5258