[llvm-commits] CVS: llvm/lib/Target/X86/README.txt
Chris Lattner
lattner at cs.uiuc.edu
Thu Feb 16 20:20:25 PST 2006
Changes in directory llvm/lib/Target/X86:
README.txt updated: 1.56 -> 1.57
---
Log message:
add note about div by power of 2
---
Diffs of the changes: (+32 -0)
README.txt | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+)
Index: llvm/lib/Target/X86/README.txt
diff -u llvm/lib/Target/X86/README.txt:1.56 llvm/lib/Target/X86/README.txt:1.57
--- llvm/lib/Target/X86/README.txt:1.56 Thu Feb 16 18:04:28 2006
+++ llvm/lib/Target/X86/README.txt Thu Feb 16 22:20:13 2006
@@ -443,3 +443,35 @@
It's not clear whether we should use pxor or xorps / xorpd to clear XMM
registers. The choice may depend on subtarget information. We should do some
more experiments on different x86 machines.
+
+//===---------------------------------------------------------------------===//
+
+Evaluate what the best way to codegen sdiv X, (2^C) is. For X/8, we currently
+get this:
+
+int %test1(int %X) {
+ %Y = div int %X, 8
+ ret int %Y
+}
+
+_test1:
+ movl 4(%esp), %eax
+ movl %eax, %ecx
+ sarl $31, %ecx
+ shrl $29, %ecx
+ addl %ecx, %eax
+ sarl $3, %eax
+ ret
+
+GCC knows several different ways to codegen it, one of which is this:
+
+_test1:
+ movl 4(%esp), %eax
+ cmpl $-1, %eax
+ leal 7(%eax), %ecx
+ cmovle %ecx, %eax
+ sarl $3, %eax
+ ret
+
+which is probably slower, but it's interesting at least :)
+
More information about the llvm-commits
mailing list