aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/X86/README.txt
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-09-13 23:37:16 +0000
committerChris Lattner <sabre@nondot.org>2006-09-13 23:37:16 +0000
commit08c33011d1443ce3e12b6c4026cde975b24c8e37 (patch)
tree4109cbde55ce425adfc78ab117b0d3a96bcaf28e /lib/Target/X86/README.txt
parenta4646b61e48453e343730103d3ad689be493a371 (diff)
downloadexternal_llvm-08c33011d1443ce3e12b6c4026cde975b24c8e37.zip
external_llvm-08c33011d1443ce3e12b6c4026cde975b24c8e37.tar.gz
external_llvm-08c33011d1443ce3e12b6c4026cde975b24c8e37.tar.bz2
add note about switch lowering
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/README.txt')
-rw-r--r--lib/Target/X86/README.txt29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Target/X86/README.txt b/lib/Target/X86/README.txt
index 14ea97d..72223d1 100644
--- a/lib/Target/X86/README.txt
+++ b/lib/Target/X86/README.txt
@@ -607,6 +607,34 @@ or eax, 2
cmp eax, 6
jz label
+If we aren't going to do this, we should lower the switch better. We compile
+the code to:
+
+_f:
+ movl 8(%esp), %eax
+ movl 4(%esp), %ecx
+ cmpl $6, %ecx
+ jl LBB1_4 #entry
+ jmp LBB1_3 #entry
+LBB1_3: #entry
+ cmpl $6, %ecx
+ je LBB1_1 #bb
+ jmp LBB1_2 #UnifiedReturnBlock
+LBB1_4: #entry
+ cmpl $4, %ecx
+ jne LBB1_2 #UnifiedReturnBlock
+LBB1_1: #bb
+ incl %eax
+ ret
+LBB1_2: #UnifiedReturnBlock
+ ret
+
+In the code above, the 'if' is turned into a 'switch' at the mid-level. It looks
+like the 'lower to branches' mode could be improved a little here. In particular,
+the fall-through to LBB1_3 doesn't need a branch. It would also be nice to
+eliminate the redundant "cmp 6", maybe by lowering to a linear sequence of
+compares if there are below a certain number of cases (instead of a binary sequence)?
+
//===---------------------------------------------------------------------===//
Compile:
@@ -675,3 +703,4 @@ _f:
etc.
//===---------------------------------------------------------------------===//
+