[llvm-commits] CVS: llvm/lib/Target/X86/README.txt

Chris Lattner sabre at nondot.org
Sun Jan 14 22:25:55 PST 2007



Changes in directory llvm/lib/Target/X86:

README.txt updated: 1.151 -> 1.152
---
Log message:

add some notes


---
Diffs of the changes:  (+68 -0)

 README.txt |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+)


Index: llvm/lib/Target/X86/README.txt
diff -u llvm/lib/Target/X86/README.txt:1.151 llvm/lib/Target/X86/README.txt:1.152
--- llvm/lib/Target/X86/README.txt:1.151	Fri Jan 12 13:20:47 2007
+++ llvm/lib/Target/X86/README.txt	Mon Jan 15 00:25:39 2007
@@ -762,3 +762,71 @@
 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.
+






More information about the llvm-commits mailing list