Give AsmPrinter the most common expected implementation of
[oota-llvm.git] / lib / Target / PowerPC / README.txt
index f5e50fc808a8d87ebe3547e0c5d3eaa2a5c20df6..8f265cfc488b019a683e4191814ecdca1e821bd1 100644 (file)
@@ -5,6 +5,39 @@ TODO:
 * implement do-loop -> bdnz transform
 * lmw/stmw pass a la arm load store optimizer for prolog/epilog
 
+===-------------------------------------------------------------------------===
+
+On PPC64, this:
+
+long f2 (long x) { return 0xfffffff000000000UL; }
+long f3 (long x) { return 0x1ffffffffUL; }
+
+could compile into:
+
+_f2:
+       li r3,-1
+       rldicr r3,r3,0,27
+       blr
+_f3:
+       li r3,-1
+       rldicl r3,r3,0,31
+       blr
+
+we produce:
+
+_f2:
+       lis r2, 4095
+       ori r2, r2, 65535
+       sldi r3, r2, 36
+       blr 
+_f3:
+       li r2, 1
+       sldi r2, r2, 32
+       oris r2, r2, 65535
+       ori r3, r2, 65535
+       blr 
+
+
 ===-------------------------------------------------------------------------===
 
 Support 'update' load/store instructions.  These are cracked on the G5, but are
@@ -397,6 +430,35 @@ This theoretically may help improve twolf slightly (used in dimbox.c:142?).
 
 ===-------------------------------------------------------------------------===
 
+PR5945: This: 
+define i32 @clamp0g(i32 %a) {
+entry:
+        %cmp = icmp slt i32 %a, 0
+        %sel = select i1 %cmp, i32 0, i32 %a
+        ret i32 %sel
+}
+
+Is compile to this with the PowerPC (32-bit) backend:
+
+_clamp0g:
+        cmpwi cr0, r3, 0
+        li r2, 0
+        blt cr0, LBB1_2
+; BB#1:                                                     ; %entry
+        mr r2, r3
+LBB1_2:                                                     ; %entry
+        mr r3, r2
+        blr
+
+This could be reduced to the much simpler:
+
+_clamp0g:
+        srawi r2, r3, 31
+        andc r3, r3, r2
+        blr
+
+===-------------------------------------------------------------------------===
+
 int foo(int N, int ***W, int **TK, int X) {
   int t, i;
   
@@ -602,6 +664,32 @@ This sort of thing occurs a lot due to globalopt.
 
 ===-------------------------------------------------------------------------===
 
+We compile:
+
+define i32 @bar(i32 %x) nounwind readnone ssp {
+entry:
+  %0 = icmp eq i32 %x, 0                          ; <i1> [#uses=1]
+  %neg = sext i1 %0 to i32              ; <i32> [#uses=1]
+  ret i32 %neg
+}
+
+to:
+
+_bar:
+       cntlzw r2, r3
+       slwi r2, r2, 26
+       srawi r3, r2, 31
+       blr 
+
+it would be better to produce:
+
+_bar: 
+        addic r3,r3,-1
+        subfe r3,r3,r3
+        blr
+
+===-------------------------------------------------------------------------===
+
 We currently compile 32-bit bswap:
 
 declare i32 @llvm.bswap.i32(i32 %A)