Chris Lattner | 1171ff4 | 2005-10-23 19:52:42 +0000 | [diff] [blame] | 1 | //===---------------------------------------------------------------------===// |
| 2 | // Random ideas for the X86 backend. |
| 3 | //===---------------------------------------------------------------------===// |
| 4 | |
| 5 | Add a MUL2U and MUL2S nodes to represent a multiply that returns both the |
| 6 | Hi and Lo parts (combination of MUL and MULH[SU] into one node). Add this to |
| 7 | X86, & make the dag combiner produce it when needed. This will eliminate one |
| 8 | imul from the code generated for: |
| 9 | |
| 10 | long long test(long long X, long long Y) { return X*Y; } |
| 11 | |
| 12 | by using the EAX result from the mul. We should add a similar node for |
| 13 | DIVREM. |
| 14 | |
| 15 | //===---------------------------------------------------------------------===// |
| 16 | |
| 17 | This should be one DIV/IDIV instruction, not a libcall: |
| 18 | |
| 19 | unsigned test(unsigned long long X, unsigned Y) { |
| 20 | return X/Y; |
| 21 | } |
| 22 | |
| 23 | This can be done trivially with a custom legalizer. What about overflow |
| 24 | though? http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14224 |
| 25 | |
| 26 | //===---------------------------------------------------------------------===// |
| 27 | |
| 28 | Need to add support for rotate instructions. |
| 29 | |
| 30 | //===---------------------------------------------------------------------===// |
| 31 | |
| 32 | Some targets (e.g. athlons) prefer freep to fstp ST(0): |
| 33 | http://gcc.gnu.org/ml/gcc-patches/2004-04/msg00659.html |
| 34 | |
| 35 | //===---------------------------------------------------------------------===// |
| 36 | |
| 37 | This should use faddi on chips where it is profitable: |
| 38 | double foo(double P, int *I) { return P+*I; } |
| 39 | |
| 40 | //===---------------------------------------------------------------------===// |
| 41 | |
| 42 | The FP stackifier needs to be global. Also, it should handle simple permutates |
| 43 | to reduce number of shuffle instructions, e.g. turning: |
| 44 | |
| 45 | fld P -> fld Q |
| 46 | fld Q fld P |
| 47 | fxch |
| 48 | |
| 49 | or: |
| 50 | |
| 51 | fxch -> fucomi |
| 52 | fucomi jl X |
| 53 | jg X |
| 54 | |
| 55 | //===---------------------------------------------------------------------===// |
| 56 | |
| 57 | Improvements to the multiply -> shift/add algorithm: |
| 58 | http://gcc.gnu.org/ml/gcc-patches/2004-08/msg01590.html |
| 59 | |
| 60 | //===---------------------------------------------------------------------===// |
| 61 | |
| 62 | Improve code like this (occurs fairly frequently, e.g. in LLVM): |
| 63 | long long foo(int x) { return 1LL << x; } |
| 64 | |
| 65 | http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01109.html |
| 66 | http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01128.html |
| 67 | http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01136.html |
| 68 | |
| 69 | Another useful one would be ~0ULL >> X and ~0ULL << X. |
| 70 | |
Chris Lattner | ffff617 | 2005-10-23 21:44:59 +0000 | [diff] [blame] | 71 | //===---------------------------------------------------------------------===// |
| 72 | |
| 73 | Should support emission of the bswap instruction, probably by adding a new |
| 74 | DAG node for byte swapping. Also useful on PPC which has byte-swapping loads. |
| 75 | |
Chris Lattner | 1e4ed93 | 2005-11-28 04:52:39 +0000 | [diff] [blame^] | 76 | //===---------------------------------------------------------------------===// |
| 77 | |
| 78 | Compile this: |
| 79 | _Bool f(_Bool a) { return a!=1; } |
| 80 | |
| 81 | into: |
| 82 | movzbl %dil, %eax |
| 83 | xorl $1, %eax |
| 84 | ret |