add a note about overflow idiom recognition.
authorChris Lattner <sabre@nondot.org>
Wed, 15 Dec 2010 07:25:55 +0000 (07:25 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 15 Dec 2010 07:25:55 +0000 (07:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121853 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/README.txt

index 17617ad547357351d813034aa85b934497517399..e59c28697a196c47f4c6f83f881c59e029217b9c 100644 (file)
@@ -73,7 +73,25 @@ This has a number of uses:
 
 //===---------------------------------------------------------------------===//
 
-Make the PPC branch selector target independant
+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
 
 //===---------------------------------------------------------------------===//