diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-18 05:35:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-18 05:35:49 +0000 |
commit | c1e4ce6044a60a0e61bed0a719ad9deec60af0eb (patch) | |
tree | 30218d4291ad7473d2a3d45febc30f5184161893 | |
parent | 67982da351c93358080c79733630c59b55891d39 (diff) |
add a poor division by constant case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125832 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/README.txt | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/Target/X86/README.txt b/lib/Target/X86/README.txt index 551d9f0852..a7a477d2d5 100644 --- a/lib/Target/X86/README.txt +++ b/lib/Target/X86/README.txt @@ -1884,3 +1884,40 @@ _add32carry: ret //===---------------------------------------------------------------------===// + +This: +char t(char c) { + return c/3; +} + +Compiles to: $clang t.c -S -o - -O3 -mkernel -fomit-frame-pointer + +_t: ## @t + movslq %edi, %rax + imulq $-1431655765, %rax, %rcx ## imm = 0xFFFFFFFFAAAAAAAB + shrq $32, %rcx + addl %ecx, %eax + movl %eax, %ecx + shrl $31, %ecx + shrl %eax + addl %ecx, %eax + movsbl %al, %eax + ret + +GCC gets: + +_t: + movl $86, %eax + imulb %dil + shrw $8, %ax + sarb $7, %dil + subb %dil, %al + movsbl %al,%eax + ret + +which is nicer. This also happens for int, not just char. + +//===---------------------------------------------------------------------===// + + + |