diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-07-13 22:27:52 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-07-13 22:27:52 +0000 |
commit | 7e1716dc9d5cbbadbcdaf8d68948eedb9fbf0c53 (patch) | |
tree | b65e1a619c035db150ef4d90c28a0cfb0cd6be18 /llvm/test/Transforms/InstCombine/zext-bool-add-sub.ll | |
parent | dd707af3456fe9bd1ac44086e6ffe457b1ed6b2b (diff) | |
download | bcm5719-llvm-7e1716dc9d5cbbadbcdaf8d68948eedb9fbf0c53.tar.gz bcm5719-llvm-7e1716dc9d5cbbadbcdaf8d68948eedb9fbf0c53.zip |
Canonicalize boolean +/- a constant to a select.
(I think it's reasonably clear that we want to have a canonical form for
constructs like this; if anyone thinks that a select is not the best
canonical form, please tell me.)
llvm-svn: 75531
Diffstat (limited to 'llvm/test/Transforms/InstCombine/zext-bool-add-sub.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/zext-bool-add-sub.ll | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/zext-bool-add-sub.ll b/llvm/test/Transforms/InstCombine/zext-bool-add-sub.ll new file mode 100644 index 00000000000..105fa171c0b --- /dev/null +++ b/llvm/test/Transforms/InstCombine/zext-bool-add-sub.ll @@ -0,0 +1,31 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {zext } | count 0 + +define i32 @a(i1 %x) { +entry: + %y = zext i1 %x to i32 + %res = add i32 %y, 1 + ret i32 %res +} + +define i32 @b(i1 %x) { +entry: + %y = zext i1 %x to i32 + %res = add i32 %y, -1 + ret i32 %res +} + +define i32 @c(i1 %x) { +entry: + %y = zext i1 %x to i32 + %res = sub i32 0, %y + ret i32 %res +} + +define i32 @d(i1 %x) { +entry: + %y = zext i1 %x to i32 + %res = sub i32 3, %y + ret i32 %res +} + + |