Open okuraofvegetable opened 4 years ago
グローバル配列、タプルの埋め込みによりグローバル配列へのアクセスは定数番地へのアクセスに変わる。アクセスのコード片をのぞき穴で最適化できる
solver_secondの周辺でやばめの断片が大量に見える
lw $6, 32($2)
lw $6, 28($2)
lw $6, 24($2)
lw $6, 20($2)
lw $6, 16($2)
lw $6, 12($2)
lw $6, 8($2)
lw $6, 4($2)
lw $6, 0($2)
redundantなloadと定数畳みこみ(Liした直後に同じレジスタにaddiするのを1回のLiにする)をやった ある程度効果はあったっぽい(48億->40億くらい)
solver系関数(死ぬほど呼ばれる)内に上のような冗長なlwがまだあった。自分の想定しているパターンに引っかかっていないのでasmをプリントして構造を特定して取り除こうと思う。
IfEq(x,y,e1,e2)のe1,e2,とかに最適化か届いていなかった。Asm.t用とAsm.exp用の関数をつくって相互再帰させてとりあえず冗長なloadはだいたい消した。
この改善で39億(1st,最適化なしinline100)から33.7億に。13%程度削減できた
inline100の26587行目くらいを見ると
addi $10, $0, 3624
add $30, $0, $10
sf $f0, 0($30)
というパターンが見えた、これはStw(hoge,x,V(reg_zero))の形の時に無駄な計算をしている。これをStw(hoge,x,C(0))に置き換えるような最適化をする
Let((y1,t1),Lwz(x1,i1),Let((y2,t2),Lwz(x2,i2),e1)) の時i2がV(y1)となる可能性を考慮していなかった、i2にy1が入っていないかチェックするようにしたら直った
addi $9,$9,3004
lw $5, 4($9)
みたいなものを
lw $5, 3008($9)
addi $9,$9,3004
に置き換えた (後ろに移ったaddiは不要定義削除で消える可能性があるので嬉しい)