[llvm-commits] [llvm] r107565 - /llvm/trunk/lib/Target/README.txt
Eli Friedman
eli.friedman at gmail.com
Sat Jul 3 00:38:13 PDT 2010
Author: efriedma
Date: Sat Jul 3 02:38:12 2010
New Revision: 107565
URL: http://llvm.org/viewvc/llvm-project?rev=107565&view=rev
Log:
Note switch-lowering inefficiency.
Modified:
llvm/trunk/lib/Target/README.txt
Modified: llvm/trunk/lib/Target/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=107565&r1=107564&r2=107565&view=diff
==============================================================================
--- llvm/trunk/lib/Target/README.txt (original)
+++ llvm/trunk/lib/Target/README.txt Sat Jul 3 02:38:12 2010
@@ -1888,3 +1888,39 @@
(That said, we are doing a lot better than gcc on this testcase. :) )
//===---------------------------------------------------------------------===//
+
+Switch lowering generates less than ideal code for the following switch:
+define void @a(i32 %x) nounwind {
+entry:
+ switch i32 %x, label %if.end [
+ i32 0, label %if.then
+ i32 1, label %if.then
+ i32 2, label %if.then
+ i32 3, label %if.then
+ i32 5, label %if.then
+ ]
+if.then:
+ tail call void @foo() nounwind
+ ret void
+if.end:
+ ret void
+}
+declare void @foo()
+
+Generated code on x86-64 (other platforms give similar results):
+a:
+ cmpl $5, %edi
+ ja .LBB0_2
+ movl %edi, %eax
+ movl $47, %ecx
+ btq %rax, %rcx
+ jb .LBB0_3
+.LBB0_2:
+ ret
+.LBB0_3:
+ xorb %al, %al
+ jmp foo at PLT # TAILCALL
+
+The movl+movl+btq+jb could be simplified to a cmpl+jne.
+
+//===---------------------------------------------------------------------===//
More information about the llvm-commits
mailing list