Dwarf requires variable entries to be in the source order. Right now, since we are...
[oota-llvm.git] / lib / Target / README.txt
index 26bc5e8319193ba1d2e676c7c1cf0198edf86c13..623c86f3555f761e0165d0341a10e1274c6281cc 100644 (file)
@@ -519,3 +519,105 @@ function, they should be sunk into the ones that do.
 In this case, whole-function-isel would also handle this.
 
 //===---------------------------------------------------------------------===//
+
+Investigate lowering of sparse switch statements into perfect hash tables:
+http://burtleburtle.net/bob/hash/perfect.html
+
+//===---------------------------------------------------------------------===//
+
+We should turn things like "load+fabs+store" and "load+fneg+store" into the
+corresponding integer operations.  On a yonah, this loop:
+
+double a[256];
+ for (b = 0; b < 10000000; b++)
+ for (i = 0; i < 256; i++)
+   a[i] = -a[i];
+
+is twice as slow as this loop:
+
+long long a[256];
+ for (b = 0; b < 10000000; b++)
+ for (i = 0; i < 256; i++)
+   a[i] ^= (1ULL << 63);
+
+and I suspect other processors are similar.  On X86 in particular this is a
+big win because doing this with integers allows the use of read/modify/write
+instructions.
+
+//===---------------------------------------------------------------------===//
+
+DAG Combiner should try to combine small loads into larger loads when 
+profitable.  For example, we compile this C++ example:
+
+struct THotKey { short Key; bool Control; bool Shift; bool Alt; };
+extern THotKey m_HotKey;
+THotKey GetHotKey () { return m_HotKey; }
+
+into (-O3 -fno-exceptions -static -fomit-frame-pointer):
+
+__Z9GetHotKeyv:
+       pushl   %esi
+       movl    8(%esp), %eax
+       movb    _m_HotKey+3, %cl
+       movb    _m_HotKey+4, %dl
+       movb    _m_HotKey+2, %ch
+       movw    _m_HotKey, %si
+       movw    %si, (%eax)
+       movb    %ch, 2(%eax)
+       movb    %cl, 3(%eax)
+       movb    %dl, 4(%eax)
+       popl    %esi
+       ret     $4
+
+GCC produces:
+
+__Z9GetHotKeyv:
+       movl    _m_HotKey, %edx
+       movl    4(%esp), %eax
+       movl    %edx, (%eax)
+       movzwl  _m_HotKey+4, %edx
+       movw    %dx, 4(%eax)
+       ret     $4
+
+The LLVM IR contains the needed alignment info, so we should be able to 
+merge the loads and stores into 4-byte loads:
+
+       %struct.THotKey = type { i16, i8, i8, i8 }
+define void @_Z9GetHotKeyv(%struct.THotKey* sret  %agg.result) nounwind  {
+...
+       %tmp2 = load i16* getelementptr (@m_HotKey, i32 0, i32 0), align 8
+       %tmp5 = load i8* getelementptr (@m_HotKey, i32 0, i32 1), align 2
+       %tmp8 = load i8* getelementptr (@m_HotKey, i32 0, i32 2), align 1
+       %tmp11 = load i8* getelementptr (@m_HotKey, i32 0, i32 3), align 2
+
+Alternatively, we should use a small amount of base-offset alias analysis
+to make it so the scheduler doesn't need to hold all the loads in regs at
+once.
+
+//===---------------------------------------------------------------------===//
+
+We should extend parameter attributes to capture more information about
+pointer parameters for alias analysis.  Some ideas:
+
+1. Add a "nocapture" attribute, which indicates that the callee does not store
+   the address of the parameter into a global or any other memory location
+   visible to the callee.  This can be used to make basicaa and other analyses
+   more powerful.  It is true for things like memcpy, strcat, and many other
+   things, including structs passed by value, most C++ references, etc.
+2. Generalize readonly to be set on parameters.  This is important mod/ref 
+   info for the function, which is important for basicaa and others.  It can
+   also be used by the inliner to avoid inserting a memcpy for byval 
+   arguments when the function is inlined.
+
+These functions can be inferred by various analysis passes such as the 
+globalsmodrefaa pass.  Note that getting #2 right is actually really tricky.
+Consider this code:
+
+struct S;  S G;
+void caller(S byvalarg) { G.field = 1; ... }
+void callee() { caller(G); }
+
+The fact that the caller does not modify byval arg is not enough, we need
+to know that it doesn't modify G either.  This is very tricky.
+
+//===---------------------------------------------------------------------===//