diff options
Diffstat (limited to 'lib/Target/X86/README.txt')
-rw-r--r-- | lib/Target/X86/README.txt | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/lib/Target/X86/README.txt b/lib/Target/X86/README.txt index 560947a..b407955 100644 --- a/lib/Target/X86/README.txt +++ b/lib/Target/X86/README.txt @@ -2,11 +2,6 @@ // Random ideas for the X86 backend. //===---------------------------------------------------------------------===// -We should add support for the "movbe" instruction, which does a byte-swapping -copy (3-addr bswap + memory support?) This is available on Atom processors. - -//===---------------------------------------------------------------------===// - This should be one DIV/IDIV instruction, not a libcall: unsigned test(unsigned long long X, unsigned Y) { @@ -1222,7 +1217,7 @@ Also check why xmm7 is not used at all in the function. Take the following: -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-S128" target triple = "i386-apple-darwin8" @in_exit.4870.b = internal global i1 false ; <i1*> [#uses=2] define fastcc void @abort_gzip() noreturn nounwind { @@ -2066,3 +2061,34 @@ The trick is to match "fetch_and_add(X, -C) == C". //===---------------------------------------------------------------------===// +unsigned log2(unsigned x) { + return x > 1 ? 32-__builtin_clz(x-1) : 0; +} + +generates (x86_64): + xorl %eax, %eax + cmpl $2, %edi + jb LBB0_2 +## BB#1: + decl %edi + movl $63, %ecx + bsrl %edi, %eax + cmovel %ecx, %eax + xorl $-32, %eax + addl $33, %eax +LBB0_2: + ret + +The cmov and the early test are redundant: + xorl %eax, %eax + cmpl $2, %edi + jb LBB0_2 +## BB#1: + decl %edi + bsrl %edi, %eax + xorl $-32, %eax + addl $33, %eax +LBB0_2: + ret + +//===---------------------------------------------------------------------===// |