Even more explanation.
[oota-llvm.git] / lib / Target / PowerPC / README.txt
index 55baf8d270ade8a0387ba6f00c02d383fc5b9373..060d6a5c5c2b9d13a33cf92c547220cfa526cc3a 100644 (file)
@@ -3,9 +3,41 @@
 TODO:
 * gpr0 allocation
 * implement do-loop -> bdnz transform
-* Implement __builtin_trap (ISD::TRAP) as 'tw 31, 0, 0' aka 'trap'.
 * 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
@@ -150,7 +182,7 @@ http://gcc.gnu.org/ml/gcc-patches/2006-02/msg00133.html
 
 Implement Newton-Rhapson method for improving estimate instructions to the
 correct accuracy, and implementing divide as multiply by reciprocal when it has
-more than one use.  Itanium will want this too.
+more than one use.  Itanium would want this too.
 
 ===-------------------------------------------------------------------------===
 
@@ -181,6 +213,16 @@ void bar() { struct foo R = { 1.0, 2.0 }; xxx(R); }
 
 ===-------------------------------------------------------------------------===
 
+Darwin Stub removal:
+
+We still generate calls to foo$stub, and stubs, on Darwin.  This is not
+necessary when building with the Leopard (10.5) or later linker, as stubs are
+generated by ld when necessary.  Parameterizing this based on the deployment
+target (-mmacosx-version-min) is probably enough.  x86-32 does this right, see
+its logic.
+
+===-------------------------------------------------------------------------===
+
 Darwin Stub LICM optimization:
 
 Loops like this:
@@ -753,3 +795,48 @@ LBB2_1:    ; bb
 The 'mr' could be eliminated to folding the add into the cmp better.
 
 //===---------------------------------------------------------------------===//
+Codegen for the following (low-probability) case deteriorated considerably 
+when the correctness fixes for unordered comparisons went in (PR 642, 58871).
+It should be possible to recover the code quality described in the comments.
+
+; RUN: llvm-as < %s | llc -march=ppc32  | grep or | count 3
+; This should produce one 'or' or 'cror' instruction per function.
+
+; RUN: llvm-as < %s | llc -march=ppc32  | grep mfcr | count 3
+; PR2964
+
+define i32 @test(double %x, double %y) nounwind  {
+entry:
+       %tmp3 = fcmp ole double %x, %y          ; <i1> [#uses=1]
+       %tmp345 = zext i1 %tmp3 to i32          ; <i32> [#uses=1]
+       ret i32 %tmp345
+}
+
+define i32 @test2(double %x, double %y) nounwind  {
+entry:
+       %tmp3 = fcmp one double %x, %y          ; <i1> [#uses=1]
+       %tmp345 = zext i1 %tmp3 to i32          ; <i32> [#uses=1]
+       ret i32 %tmp345
+}
+
+define i32 @test3(double %x, double %y) nounwind  {
+entry:
+       %tmp3 = fcmp ugt double %x, %y          ; <i1> [#uses=1]
+       %tmp34 = zext i1 %tmp3 to i32           ; <i32> [#uses=1]
+       ret i32 %tmp34
+}
+//===----------------------------------------------------------------------===//
+; RUN: llvm-as < %s | llc -march=ppc32 | not grep fneg
+
+; This could generate FSEL with appropriate flags (FSEL is not IEEE-safe, and 
+; should not be generated except with -enable-finite-only-fp-math or the like).
+; With the correctness fixes for PR642 (58871) LowerSELECT_CC would need to
+; recognize a more elaborate tree than a simple SETxx.
+
+define double @test_FNEG_sel(double %A, double %B, double %C) {
+        %D = sub double -0.000000e+00, %A               ; <double> [#uses=1]
+        %Cond = fcmp ugt double %D, -0.000000e+00               ; <i1> [#uses=1]
+        %E = select i1 %Cond, double %B, double %C              ; <double> [#uses=1]
+        ret double %E
+}
+