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 | |
Chris Lattner | 865874c | 2005-12-02 00:11:20 +0000 | [diff] [blame] | 15 | another case is: |
| 16 | |
| 17 | long long test(int X, int Y) { return (long long)X*Y; } |
| 18 | |
| 19 | ... which should only be one imul instruction. |
| 20 | |
Chris Lattner | 1171ff4 | 2005-10-23 19:52:42 +0000 | [diff] [blame] | 21 | //===---------------------------------------------------------------------===// |
| 22 | |
| 23 | This should be one DIV/IDIV instruction, not a libcall: |
| 24 | |
| 25 | unsigned test(unsigned long long X, unsigned Y) { |
| 26 | return X/Y; |
| 27 | } |
| 28 | |
| 29 | This can be done trivially with a custom legalizer. What about overflow |
| 30 | though? http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14224 |
| 31 | |
| 32 | //===---------------------------------------------------------------------===// |
| 33 | |
| 34 | Need to add support for rotate instructions. |
| 35 | |
| 36 | //===---------------------------------------------------------------------===// |
| 37 | |
| 38 | Some targets (e.g. athlons) prefer freep to fstp ST(0): |
| 39 | http://gcc.gnu.org/ml/gcc-patches/2004-04/msg00659.html |
| 40 | |
| 41 | //===---------------------------------------------------------------------===// |
| 42 | |
| 43 | This should use faddi on chips where it is profitable: |
| 44 | double foo(double P, int *I) { return P+*I; } |
| 45 | |
| 46 | //===---------------------------------------------------------------------===// |
| 47 | |
| 48 | The FP stackifier needs to be global. Also, it should handle simple permutates |
| 49 | to reduce number of shuffle instructions, e.g. turning: |
| 50 | |
| 51 | fld P -> fld Q |
| 52 | fld Q fld P |
| 53 | fxch |
| 54 | |
| 55 | or: |
| 56 | |
| 57 | fxch -> fucomi |
| 58 | fucomi jl X |
| 59 | jg X |
| 60 | |
| 61 | //===---------------------------------------------------------------------===// |
| 62 | |
| 63 | Improvements to the multiply -> shift/add algorithm: |
| 64 | http://gcc.gnu.org/ml/gcc-patches/2004-08/msg01590.html |
| 65 | |
| 66 | //===---------------------------------------------------------------------===// |
| 67 | |
| 68 | Improve code like this (occurs fairly frequently, e.g. in LLVM): |
| 69 | long long foo(int x) { return 1LL << x; } |
| 70 | |
| 71 | http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01109.html |
| 72 | http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01128.html |
| 73 | http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01136.html |
| 74 | |
| 75 | Another useful one would be ~0ULL >> X and ~0ULL << X. |
| 76 | |
Chris Lattner | ffff617 | 2005-10-23 21:44:59 +0000 | [diff] [blame] | 77 | //===---------------------------------------------------------------------===// |
| 78 | |
| 79 | Should support emission of the bswap instruction, probably by adding a new |
| 80 | DAG node for byte swapping. Also useful on PPC which has byte-swapping loads. |
| 81 | |
Chris Lattner | 1e4ed93 | 2005-11-28 04:52:39 +0000 | [diff] [blame] | 82 | //===---------------------------------------------------------------------===// |
| 83 | |
| 84 | Compile this: |
| 85 | _Bool f(_Bool a) { return a!=1; } |
| 86 | |
| 87 | into: |
| 88 | movzbl %dil, %eax |
| 89 | xorl $1, %eax |
| 90 | ret |
Evan Cheng | 8dee8cc | 2005-12-17 01:25:19 +0000 | [diff] [blame] | 91 | |
| 92 | //===---------------------------------------------------------------------===// |
| 93 | |
| 94 | Some isel ideas: |
| 95 | |
| 96 | 1. Dynamic programming based approach when compile time if not an |
| 97 | issue. |
| 98 | 2. Code duplication (addressing mode) during isel. |
| 99 | 3. Other ideas from "Register-Sensitive Selection, Duplication, and |
| 100 | Sequencing of Instructions". |
| 101 | |
| 102 | //===---------------------------------------------------------------------===// |
| 103 | |
| 104 | Should we promote i16 to i32 to avoid partial register update stalls? |
Evan Cheng | 98abbfb | 2005-12-17 06:54:43 +0000 | [diff] [blame^] | 105 | |
| 106 | //===---------------------------------------------------------------------===// |
| 107 | |
| 108 | Leave any_extend as pseudo instruction and hint to register |
| 109 | allocator. Delay codegen until post register allocation. |