summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-19 19:37:52 +0000
committerChris Lattner <sabre@nondot.org>2010-12-19 19:37:52 +0000
commit5e0c0c72e9da9a8f151e770aea709eb169abf56a (patch)
tree8d7d24fc49bcfd1e1db9faa4816da95621bb3e8e /llvm/lib/Target
parent33dc3f0cfa89384f6b4e5684e1f17c8b8353949d (diff)
downloadbcm5719-llvm-5e0c0c72e9da9a8f151e770aea709eb169abf56a.tar.gz
bcm5719-llvm-5e0c0c72e9da9a8f151e770aea709eb169abf56a.zip
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 llvm-svn: 122182
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/README.txt21
1 files changed, 1 insertions, 20 deletions
diff --git a/llvm/lib/Target/README.txt b/llvm/lib/Target/README.txt
index 5c97b8984c1..abb8ee6f499 100644
--- a/llvm/lib/Target/README.txt
+++ b/llvm/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)
OpenPOWER on IntegriCloud