[llvm-commits] CVS: llvm/lib/Target/X86/README.txt
Chris Lattner
lattner at cs.uiuc.edu
Wed Sep 13 16:37:30 PDT 2006
Changes in directory llvm/lib/Target/X86:
README.txt updated: 1.132 -> 1.133
---
Log message:
add note about switch lowering
---
Diffs of the changes: (+29 -0)
README.txt | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+)
Index: llvm/lib/Target/X86/README.txt
diff -u llvm/lib/Target/X86/README.txt:1.132 llvm/lib/Target/X86/README.txt:1.133
--- llvm/lib/Target/X86/README.txt:1.132 Tue Sep 12 23:19:50 2006
+++ llvm/lib/Target/X86/README.txt Wed Sep 13 18:37:16 2006
@@ -607,6 +607,34 @@
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 @@
etc.
//===---------------------------------------------------------------------===//
+
More information about the llvm-commits
mailing list