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

Bob Wilson bob.wilson at apple.com
Sat Jan 28 10:30:07 PST 2012


Author: bwilson
Date: Sat Jan 28 12:30:07 2012
New Revision: 149182

URL: http://llvm.org/viewvc/llvm-project?rev=149182&view=rev
Log:
Add a note about a potential optimization for clz/ctz patterns for ARM
(and other targets).

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

Modified: llvm/trunk/lib/Target/ARM/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/README.txt?rev=149182&r1=149181&r2=149182&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/README.txt (original)
+++ llvm/trunk/lib/Target/ARM/README.txt Sat Jan 28 12:30:07 2012
@@ -699,3 +699,19 @@
 
 Currently this is a ARM specific dag combine. We probably should make it into a
 target-neutral one.
+
+//===---------------------------------------------------------------------===//
+
+Optimize unnecessary checks for zero with __builtin_clz/ctz.  Those builtins
+are specified to be undefined at zero, so portable code must check for zero
+and handle it as a special case.  That is unnecessary on ARM where those
+operations are implemented in a way that is well-defined for zero.  For
+example:
+
+int f(int x) { return x ? __builtin_clz(x) : sizeof(int)*8; }
+
+should just be implemented with a CLZ instruction.  Since there are other
+targets, e.g., PPC, that share this behavior, it would be best to implement
+this in a target-independent way: we should probably fold that (when using
+"undefined at zero" semantics) to set the "defined at zero" bit and have
+the code generator expand out the right code.





More information about the llvm-commits mailing list