Fix comment.
[oota-llvm.git] / lib / Target / X86 / README-FPStack.txt
1 //===---------------------------------------------------------------------===//
2 // Random ideas for the X86 backend: FP stack related stuff
3 //===---------------------------------------------------------------------===//
4
5 //===---------------------------------------------------------------------===//
6
7 Some targets (e.g. athlons) prefer freep to fstp ST(0):
8 http://gcc.gnu.org/ml/gcc-patches/2004-04/msg00659.html
9
10 //===---------------------------------------------------------------------===//
11
12 On darwin/x86, we should codegen:
13
14         ret double 0.000000e+00
15
16 as fld0/ret, not as:
17
18         movl $0, 4(%esp)
19         movl $0, (%esp)
20         fldl (%esp)
21         ...
22         ret
23
24 //===---------------------------------------------------------------------===//
25
26 This should use fiadd on chips where it is profitable:
27 double foo(double P, int *I) { return P+*I; }
28
29 We have fiadd patterns now but the followings have the same cost and
30 complexity. We need a way to specify the later is more profitable.
31
32 def FpADD32m  : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
33                     [(set RFP:$dst, (fadd RFP:$src1,
34                                      (extloadf64f32 addr:$src2)))]>;
35                 // ST(0) = ST(0) + [mem32]
36
37 def FpIADD32m : FpI<(ops RFP:$dst, RFP:$src1, i32mem:$src2), OneArgFPRW,
38                     [(set RFP:$dst, (fadd RFP:$src1,
39                                      (X86fild addr:$src2, i32)))]>;
40                 // ST(0) = ST(0) + [mem32int]
41
42 //===---------------------------------------------------------------------===//
43
44 The FP stackifier needs to be global.  Also, it should handle simple permutates
45 to reduce number of shuffle instructions, e.g. turning:
46
47 fld P   ->              fld Q
48 fld Q                   fld P
49 fxch
50
51 or:
52
53 fxch    ->              fucomi
54 fucomi                  jl X
55 jg X
56
57 Ideas:
58 http://gcc.gnu.org/ml/gcc-patches/2004-11/msg02410.html
59
60
61 //===---------------------------------------------------------------------===//
62
63 Add a target specific hook to DAG combiner to handle SINT_TO_FP and
64 FP_TO_SINT when the source operand is already in memory.
65
66 //===---------------------------------------------------------------------===//
67
68 Open code rint,floor,ceil,trunc:
69 http://gcc.gnu.org/ml/gcc-patches/2004-08/msg02006.html
70 http://gcc.gnu.org/ml/gcc-patches/2004-08/msg02011.html
71
72 Opencode the sincos[f] libcall.
73
74 //===---------------------------------------------------------------------===//
75
76 None of the FPStack instructions are handled in
77 X86RegisterInfo::foldMemoryOperand, which prevents the spiller from
78 folding spill code into the instructions.
79
80 //===---------------------------------------------------------------------===//
81
82 Currently the x86 codegen isn't very good at mixing SSE and FPStack
83 code:
84
85 unsigned int foo(double x) { return x; }
86
87 foo:
88         subl $20, %esp
89         movsd 24(%esp), %xmm0
90         movsd %xmm0, 8(%esp)
91         fldl 8(%esp)
92         fisttpll (%esp)
93         movl (%esp), %eax
94         addl $20, %esp
95         ret
96
97 This will be solved when we go to a dynamic programming based isel.
98
99 //===---------------------------------------------------------------------===//