aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-07-13 22:27:52 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-07-13 22:27:52 +0000
commit709b33dc78bf7836d90cc96aaabcf7835dc05b6b (patch)
tree9f9c973c2b48cd604c8efbb2a137f6dab7ea9edd /test
parentddf9f99a9face1bdfc51a5107508a64432d86ad1 (diff)
downloadexternal_llvm-709b33dc78bf7836d90cc96aaabcf7835dc05b6b.zip
external_llvm-709b33dc78bf7836d90cc96aaabcf7835dc05b6b.tar.gz
external_llvm-709b33dc78bf7836d90cc96aaabcf7835dc05b6b.tar.bz2
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.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75531 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/InstCombine/zext-bool-add-sub.ll31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/zext-bool-add-sub.ll b/test/Transforms/InstCombine/zext-bool-add-sub.ll
new file mode 100644
index 0000000..105fa17
--- /dev/null
+++ b/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
+}
+
+