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

Chris Lattner sabre at nondot.org
Thu Nov 11 10:23:57 PST 2010


Author: lattner
Date: Thu Nov 11 12:23:57 2010
New Revision: 118806

URL: http://llvm.org/viewvc/llvm-project?rev=118806&view=rev
Log:
add a note

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=118806&r1=118805&r2=118806&view=diff
==============================================================================
--- llvm/trunk/lib/Target/README.txt (original)
+++ llvm/trunk/lib/Target/README.txt Thu Nov 11 12:23:57 2010
@@ -1984,3 +1984,31 @@
 }
 
 //===---------------------------------------------------------------------===//
+
+We compile this:
+
+int foo(int a) { return (a & (~15)) / 16; }
+
+Into:
+
+define i32 @foo(i32 %a) nounwind readnone ssp {
+entry:
+  %and = and i32 %a, -16
+  %div = sdiv i32 %and, 16
+  ret i32 %div
+}
+
+but this code (X & -A)/A is X >> log2(A) when A is a power of 2, so this case
+should be instcombined into just "a >> 4".
+
+We do get this at the codegen level, so something knows about it, but 
+instcombine should catch it earlier:
+
+_foo:                                   ## @foo
+## BB#0:                                ## %entry
+	movl	%edi, %eax
+	sarl	$4, %eax
+	ret
+
+//===---------------------------------------------------------------------===//
+





More information about the llvm-commits mailing list