cpuex2019-1 / compiler

Other
0 stars 0 forks source link

最適化全般 #15

Open okuraofvegetable opened 4 years ago

okuraofvegetable commented 4 years ago
solver_second.2875:
    lf  $f3, 0($5)
    lf  $f4, 8($5)
    lf  $f5, 16($5)
    fmul    $f6, $f3, $f3
    lw  $6, 16($2)
    lw  $7, 0($2)
    lf  $f7, 0($6)
    fmul    $f6, $f6, $f7
    fmul    $f7, $f4, $f4
    lw  $6, 16($2)
    lw  $7, 0($2)
    lf  $f8, 8($6)
    fmul    $f7, $f7, $f8
    fadd    $f6, $f6, $f7
    fmul    $f7, $f5, $f5
    lw  $6, 16($2)
    lw  $7, 0($2)
    lf  $f8, 16($6)
    fmul    $f7, $f7, $f8
    fadd    $f6, $f6, $f7
    lw  $6, 12($2)
    lw  $7, 0($2)

無駄なLoad

okuraofvegetable commented 4 years ago

アセンブリのジャンプの連鎖を削除したい

okuraofvegetable commented 4 years ago

ライブラリ関数の改善

okuraofvegetable commented 4 years ago

kNormalのfvをメモ化したらコンパイルがめっちゃ早くなった。

okuraofvegetable commented 4 years ago

Asm.tの定数畳み込みを実装した。constFoldAsmとelimAsmで変化がなくなるまで最適化。

okuraofvegetable commented 4 years ago

sakakuraがelim_asmの副作用判定のAnsをtrueにしたまま戻し忘れてたのを見つけてくれたので直したが消える個数は変わらなかった。IfEqで再帰的に副作用判定するときはかならずtrueになっているっぽい(?)

okuraofvegetable commented 4 years ago

image_sizeなどのグローバル配列は一度しか書き込みがおこらない。なんとか解析して書き込み後に定数扱いして定数畳みこみに反映させたい(div10とかもこれで消える)

okuraofvegetable commented 4 years ago
okuraofvegetable commented 4 years ago

ライブラリのfisposなどが

let rec fispos =
  if x > 0.0 then true else false
in

になっていたが、これを

let rec fispos x = ( x > 0.0) in

に直すとかなり命令数が減った

okuraofvegetable commented 4 years ago

再帰関数のインライン化のthresholdを別にして無限に展開されないようにした、これで-inline 800でもコンパイルにそんなに時間がかからないようになった。

okuraofvegetable commented 4 years ago

浮動小数の0.0レジスタを作る

okuraofvegetable commented 4 years ago

分岐が貧弱だったのでレジスタを比較して直接ジャンプする命令をシミュレータ上で導入してもらった 今はメモリアクセスのアドレシングモードが足りてないと感じている

okuraofvegetable commented 4 years ago

Sw r1 r2 r3でmem[r2+r3]にr1をStoreみたいな感じにしたい

okuraofvegetable commented 4 years ago

型を揃えるためだけのdummyはアホくさいので無視したい

okuraofvegetable commented 4 years ago

ジャンプのchainの除去(j+j,j+branch等)