summaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/switch-or.ll
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-11-22 09:45:38 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-11-22 09:45:38 +0000
commitce750f03322fe29ced3aca0718424fe173f22298 (patch)
tree19b6190877ec7040a869a2fc085811d619e9f1f3 /test/CodeGen/X86/switch-or.ll
parentb05099bf42d54838f0648569d4ae1a98dfa7da7b (diff)
downloadllvm-ce750f03322fe29ced3aca0718424fe173f22298.tar.gz
llvm-ce750f03322fe29ced3aca0718424fe173f22298.tar.bz2
llvm-ce750f03322fe29ced3aca0718424fe173f22298.tar.xz
Implement the "if (X == 6 || X == 4)" -> "if ((X|2) == 6)" optimization.
This currently only catches the most basic case, a two-case switch, but can be extended later. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119964 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/switch-or.ll')
-rw-r--r--test/CodeGen/X86/switch-or.ll22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/CodeGen/X86/switch-or.ll b/test/CodeGen/X86/switch-or.ll
new file mode 100644
index 0000000000..75832c7d30
--- /dev/null
+++ b/test/CodeGen/X86/switch-or.ll
@@ -0,0 +1,22 @@
+; RUN: llc -march=x86 -asm-verbose=false < %s | FileCheck %s
+
+; Check that merging switch cases that differ in one bit works.
+; CHECK: orl $2
+; CHECK-NEXT: cmpl $6
+
+define void @foo(i32 %variable) nounwind {
+entry:
+ switch i32 %variable, label %if.end [
+ i32 4, label %if.then
+ i32 6, label %if.then
+ ]
+
+if.then:
+ %call = tail call i32 (...)* @bar() nounwind
+ ret void
+
+if.end:
+ ret void
+}
+
+declare i32 @bar(...) nounwind