diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-07-26 22:42:13 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-07-26 22:42:13 +0000 |
commit | 162ee5c725fdfd327243dc11520afb88659f2ed4 (patch) | |
tree | 44545933139941be27214e75016dfce12c028591 /lib/Target/X86/README.txt | |
parent | 4ea496846a84918c5e5cdd67ae43d6e2b0a110ea (diff) | |
download | external_llvm-162ee5c725fdfd327243dc11520afb88659f2ed4.zip external_llvm-162ee5c725fdfd327243dc11520afb88659f2ed4.tar.gz external_llvm-162ee5c725fdfd327243dc11520afb88659f2ed4.tar.bz2 |
Add a neat little two's complement hack for x86.
On x86 we can't encode an immediate LHS of a sub directly. If the RHS comes from a XOR with a constant we can
fold the negation into the xor and add one to the immediate of the sub. Then we can turn the sub into an add,
which can be commuted and encoded efficiently.
This code is generated for __builtin_clz and friends.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136167 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/README.txt')
-rw-r--r-- | lib/Target/X86/README.txt | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/lib/Target/X86/README.txt b/lib/Target/X86/README.txt index d6ceaa7..8d9eaba 100644 --- a/lib/Target/X86/README.txt +++ b/lib/Target/X86/README.txt @@ -2076,12 +2076,11 @@ generates (x86_64): jb LBB0_2 ## BB#1: decl %edi - movl $63, %eax - bsrl %edi, %ecx - cmovel %eax, %ecx - xorl $31, %ecx - movl $32, %eax - subl %ecx, %eax + movl $63, %ecx + bsrl %edi, %eax + cmovel %ecx, %eax + xorl $-32, %eax + addl $33, %eax LBB0_2: ret @@ -2091,26 +2090,10 @@ The cmov and the early test are redundant: jb LBB0_2 ## BB#1: decl %edi - bsrl %edi, %ecx - xorl $31, %ecx - movl $32, %eax - subl %ecx, %eax + bsrl %edi, %eax + xorl $-32, %eax + addl $33, %eax LBB0_2: ret -If we want to get really fancy we could use some two's complement magic: - xorl %eax, %eax - cmpl $2, %edi - jb LBB0_2 -## BB#1: - decl %edi - bsrl %edi, %ecx - xorl $-32, %ecx - leal 33(%ecx), %eax -LBB0_2: - ret - -This is only useful on targets that can't encode the first operand of a sub -directly. The rule is C1 - (X^C2) -> (C1+1) + (X^~C2). - //===---------------------------------------------------------------------===// |