aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/X86/README.txt
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-01-21 07:03:37 +0000
committerChris Lattner <sabre@nondot.org>2007-01-21 07:03:37 +0000
commit66bb5b5db6ff03f8531bedef79d4fb2e1548f593 (patch)
tree5f5f4aeca4f7f8853ef61dc9142fce6c159394eb /lib/Target/X86/README.txt
parentfebecf4041f18b10a007ebd47ccaffdc98ea3edd (diff)
downloadexternal_llvm-66bb5b5db6ff03f8531bedef79d4fb2e1548f593.zip
external_llvm-66bb5b5db6ff03f8531bedef79d4fb2e1548f593.tar.gz
external_llvm-66bb5b5db6ff03f8531bedef79d4fb2e1548f593.tar.bz2
add a note
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33423 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/README.txt')
-rw-r--r--lib/Target/X86/README.txt52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/Target/X86/README.txt b/lib/Target/X86/README.txt
index bea5b8d..fe63e9e 100644
--- a/lib/Target/X86/README.txt
+++ b/lib/Target/X86/README.txt
@@ -830,3 +830,55 @@ _foo:
the pxor is not needed, we could compare the value against itself.
+//===---------------------------------------------------------------------===//
+
+These two functions have identical effects:
+
+unsigned int f(unsigned int i, unsigned int n) {++i; if (i == n) ++i; return i;}
+unsigned int f2(unsigned int i, unsigned int n) {++i; i += i == n; return i;}
+
+We currently compile them to:
+
+_f:
+ movl 4(%esp), %eax
+ movl %eax, %ecx
+ incl %ecx
+ movl 8(%esp), %edx
+ cmpl %edx, %ecx
+ jne LBB1_2 #UnifiedReturnBlock
+LBB1_1: #cond_true
+ addl $2, %eax
+ ret
+LBB1_2: #UnifiedReturnBlock
+ movl %ecx, %eax
+ ret
+_f2:
+ movl 4(%esp), %eax
+ movl %eax, %ecx
+ incl %ecx
+ cmpl 8(%esp), %ecx
+ sete %cl
+ movzbl %cl, %ecx
+ leal 1(%ecx,%eax), %eax
+ ret
+
+both of which are inferior to GCC's:
+
+_f:
+ movl 4(%esp), %edx
+ leal 1(%edx), %eax
+ addl $2, %edx
+ cmpl 8(%esp), %eax
+ cmove %edx, %eax
+ ret
+_f2:
+ movl 4(%esp), %eax
+ addl $1, %eax
+ xorl %edx, %edx
+ cmpl 8(%esp), %eax
+ sete %dl
+ addl %edx, %eax
+ ret
+
+//===---------------------------------------------------------------------===//
+