diff options
author | Chris Lattner <sabre@nondot.org> | 2007-01-15 06:25:39 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-01-15 06:25:39 +0000 |
commit | 7ace299bdca4c5397eb7962dc5360e693ba77e5d (patch) | |
tree | 81aa1f329fa7aa99d51ccde9802d687d05b018e4 | |
parent | b6673a9e60b1b09d2ce93a5ac9a8f7b3d861a947 (diff) |
add some notes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33228 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/README.txt | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/Target/X86/README.txt b/lib/Target/X86/README.txt index 7e365203a8..bea5b8dbca 100644 --- a/lib/Target/X86/README.txt +++ b/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. + |