summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-01-15 06:25:39 +0000
committerChris Lattner <sabre@nondot.org>2007-01-15 06:25:39 +0000
commite76908ba81439441f1d0e104dc65ee7502509a5b (patch)
treef6e9c2f3c6df3a899f31a495e1968860a104d289 /llvm
parent6eb29908104af3a4ad0ebca6149b282f9bb8a182 (diff)
downloadbcm5719-llvm-e76908ba81439441f1d0e104dc65ee7502509a5b.tar.gz
bcm5719-llvm-e76908ba81439441f1d0e104dc65ee7502509a5b.zip
add some notes
llvm-svn: 33228
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/X86/README.txt68
1 files changed, 68 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/README.txt b/llvm/lib/Target/X86/README.txt
index 7e365203a80..bea5b8dbca4 100644
--- a/llvm/lib/Target/X86/README.txt
+++ b/llvm/lib/Target/X86/README.txt
@@ -762,3 +762,71 @@ int f(char *p) {
We should inline lrintf and probably other libc functions.
//===---------------------------------------------------------------------===//
+
+Start using the flags more. For example, compile:
+
+int add_zf(int *x, int y, int a, int b) {
+ if ((*x += y) == 0)
+ return a;
+ else
+ return b;
+}
+
+to:
+ addl %esi, (%rdi)
+ movl %edx, %eax
+ cmovne %ecx, %eax
+ ret
+instead of:
+
+_add_zf:
+ addl (%rdi), %esi
+ movl %esi, (%rdi)
+ testl %esi, %esi
+ cmove %edx, %ecx
+ movl %ecx, %eax
+ ret
+
+and:
+
+int add_zf(int *x, int y, int a, int b) {
+ if ((*x + y) < 0)
+ return a;
+ else
+ return b;
+}
+
+to:
+
+add_zf:
+ addl (%rdi), %esi
+ movl %edx, %eax
+ cmovns %ecx, %eax
+ ret
+
+instead of:
+
+_add_zf:
+ addl (%rdi), %esi
+ testl %esi, %esi
+ cmovs %edx, %ecx
+ movl %ecx, %eax
+ ret
+
+//===---------------------------------------------------------------------===//
+
+This:
+#include <math.h>
+int foo(double X) { return isnan(X); }
+
+compiles to (-m64):
+
+_foo:
+ pxor %xmm1, %xmm1
+ ucomisd %xmm1, %xmm0
+ setp %al
+ movzbl %al, %eax
+ ret
+
+the pxor is not needed, we could compare the value against itself.
+
OpenPOWER on IntegriCloud