[llvm-commits] [llvm] r121853 - /llvm/trunk/lib/Target/README.txt

Chris Lattner sabre at nondot.org
Tue Dec 14 23:25:55 PST 2010


Author: lattner
Date: Wed Dec 15 01:25:55 2010
New Revision: 121853

URL: http://llvm.org/viewvc/llvm-project?rev=121853&view=rev
Log:
add a note about overflow idiom recognition.

Modified:
    llvm/trunk/lib/Target/README.txt

Modified: llvm/trunk/lib/Target/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=121853&r1=121852&r2=121853&view=diff
==============================================================================
--- llvm/trunk/lib/Target/README.txt (original)
+++ llvm/trunk/lib/Target/README.txt Wed Dec 15 01:25:55 2010
@@ -73,7 +73,25 @@
 
 //===---------------------------------------------------------------------===//
 
-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
 
 //===---------------------------------------------------------------------===//
 





More information about the llvm-commits mailing list