diff options
author | Chris Lattner <sabre@nondot.org> | 2010-12-19 19:37:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-12-19 19:37:52 +0000 |
commit | e5cbdca3bd4bc40ca31282531a9292f70648d265 (patch) | |
tree | e3ce4ae2434bb2160c3cb96db2c3379b46cbd85c /lib/Target/README.txt | |
parent | 26b482d7a76df3f67675ce852daed0eba709c63e (diff) | |
download | llvm-e5cbdca3bd4bc40ca31282531a9292f70648d265.tar.gz llvm-e5cbdca3bd4bc40ca31282531a9292f70648d265.tar.bz2 llvm-e5cbdca3bd4bc40ca31282531a9292f70648d265.tar.xz |
recognize an unsigned add with overflow idiom into uadd.
This resolves a README entry and technically resolves PR4916,
but we still get poor code for the testcase in that PR because
GVN isn't CSE'ing uadd with add, filed as PR8817.
Previously we got:
_test7: ## @test7
addq %rsi, %rdi
cmpq %rdi, %rsi
movl $42, %eax
cmovaq %rsi, %rax
ret
Now we get:
_test7: ## @test7
addq %rsi, %rdi
movl $42, %eax
cmovbq %rsi, %rax
ret
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122182 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/README.txt')
-rw-r--r-- | lib/Target/README.txt | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/lib/Target/README.txt b/lib/Target/README.txt index 5c97b8984c..abb8ee6f49 100644 --- a/lib/Target/README.txt +++ b/lib/Target/README.txt @@ -74,26 +74,7 @@ This has a number of uses: //===---------------------------------------------------------------------===// We should recognized various "overflow detection" idioms and translate them into -llvm.uadd.with.overflow and similar intrinsics. For example, we compile this: - -size_t add(size_t a,size_t b) { - if (a+b<a) - exit(0); - return a+b; -} - -into: - - addq %rdi, %rbx - cmpq %rdi, %rbx - jae LBB0_2 - -when it would be better to generate: - - addq %rdi, %rbx - jno LBB0_2 - -Apparently some version of GCC knows this. Here is a multiply idiom: +llvm.uadd.with.overflow and similar intrinsics. Here is a multiply idiom: unsigned int mul(unsigned int a,unsigned int b) { if ((unsigned long long)a*b>0xffffffff) |