blob: 4ab412238a0b794e388d8061788197aff67ff703 [file] [log] [blame]
Chris Lattnerd1aaee02006-02-03 06:21:43 +00001Target Independent Opportunities:
2
3===-------------------------------------------------------------------------===
4
5FreeBench/mason contains code like this:
6
7static p_type m0u(p_type p) {
8 int m[]={0, 8, 1, 2, 16, 5, 13, 7, 14, 9, 3, 4, 11, 12, 15, 10, 17, 6};
9 p_type pu;
10 pu.a = m[p.a];
11 pu.b = m[p.b];
12 pu.c = m[p.c];
13 return pu;
14}
15
16We currently compile this into a memcpy from a static array into 'm', then
17a bunch of loads from m. It would be better to avoid the memcpy and just do
18loads from the static array.
19
20===-------------------------------------------------------------------------===
21
22Get the C front-end to expand hypot(x,y) -> llvm.sqrt(x*x+y*y) when errno and
23precision don't matter (ffastmath). Misc/mandel will like this. :)
24
Chris Lattnerd1aaee02006-02-03 06:21:43 +000025//===---------------------------------------------------------------------===//
26
27Solve this DAG isel folding deficiency:
28
29int X, Y;
30
31void fn1(void)
32{
33 X = X | (Y << 3);
34}
35
36compiles to
37
38fn1:
39 movl Y, %eax
40 shll $3, %eax
41 orl X, %eax
42 movl %eax, X
43 ret
44
45The problem is the store's chain operand is not the load X but rather
46a TokenFactor of the load X and load Y, which prevents the folding.
47
48There are two ways to fix this:
49
501. The dag combiner can start using alias analysis to realize that y/x
51 don't alias, making the store to X not dependent on the load from Y.
522. The generated isel could be made smarter in the case it can't
53 disambiguate the pointers.
54
55Number 1 is the preferred solution.
56
Evan Cheng60f49512006-03-13 23:19:10 +000057This has been "fixed" by a TableGen hack. But that is a short term workaround
58which will be removed once the proper fix is made.
59
Chris Lattnerd1aaee02006-02-03 06:21:43 +000060//===---------------------------------------------------------------------===//
61
Chris Lattner0a08f442006-02-21 18:29:44 +000062Turn this into a signed shift right in instcombine:
63
64int f(unsigned x) {
65 return x >> 31 ? -1 : 0;
66}
67
68http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25600
69http://gcc.gnu.org/ml/gcc-patches/2006-02/msg01492.html
70
Chris Lattner90675002006-03-02 22:34:38 +000071//===---------------------------------------------------------------------===//
72
Chris Lattnere43e5c02006-03-04 01:19:34 +000073On targets with expensive 64-bit multiply, we could LSR this:
74
75for (i = ...; ++i) {
76 x = 1ULL << i;
77
78into:
79 long long tmp = 1;
80 for (i = ...; ++i, tmp+=tmp)
81 x = tmp;
82
83This would be a win on ppc32, but not x86 or ppc64.
84
Chris Lattnerc9a318d2006-03-04 08:44:51 +000085//===---------------------------------------------------------------------===//
Chris Lattner5032c322006-03-05 20:00:08 +000086
87Shrink: (setlt (loadi32 P), 0) -> (setlt (loadi8 Phi), 0)
88
89//===---------------------------------------------------------------------===//
Chris Lattnerbccb0e02006-03-07 02:46:26 +000090
91Reassociate is missing this:
92
93int test(int X, int Y) {
94 return (X+X+Y+Y); // (X+Y) << 1;
95}
96
97it needs to turn the shifts into multiplies to get it.
98
99//===---------------------------------------------------------------------===//
100
Chris Lattner003f6332006-03-11 20:17:08 +0000101Reassociate should turn: X*X*X*X -> t=(X*X) (t*t) to eliminate a multiply.
102
103//===---------------------------------------------------------------------===//
104
Chris Lattner4e56b682006-03-11 20:20:40 +0000105Interesting? testcase for add/shift/mul reassoc:
106
107int bar(int x, int y) {
108 return x*x*x+y+x*x*x*x*x*y*y*y*y;
109}
110int foo(int z, int n) {
111 return bar(z, n) + bar(2*z, 2*n);
112}
113
114//===---------------------------------------------------------------------===//
115
Chris Lattnerf1362992006-03-09 20:13:21 +0000116These two functions should generate the same code on big-endian systems:
117
118int g(int *j,int *l) { return memcmp(j,l,4); }
119int h(int *j, int *l) { return *j - *l; }
120
121this could be done in SelectionDAGISel.cpp, along with other special cases,
122for 1,2,4,8 bytes.
123
124//===---------------------------------------------------------------------===//
125