gigahorse-toolchain
gigahorse-toolchain copied to clipboard
Need some constant folding in `GlobalAnalysis`
We currently only perform constant folding at local.dl
:
https://github.com/nevillegrech/gigahorse-toolchain/blob/2c3994b1390aba93ee87922d35bb1acce618ba42/logic/local.dl#L118C1-L135C56
There are cases in which this isn't enough. Relevant snippet:
Begin block 0x4aaa0xb67
prev=[0x39db0xb67], succ=[0x4eb10xb67]
=================================
0x4aab0xb67: vb674aab(0x4abe) = CONST
0x4ab10xb67: vb674ab1(0x4e60) = CONST
0x4ab40xb67: vb674ab4(0x555f) = CONST
0x4ab70xb67: vb674ab7(0x5586) = CONST
0x4aba0xb67: vb674aba(0x4eb1) = CONST
0x4abd0xb67: JUMP vb674aba(0x4eb1)
Begin block 0x4eb10xb67
prev=[0x4aaa0xb67], succ=[]
=================================
0x4eb20xb67: vb674eb2(0x4ebf) = CONST
0x4eb80xb67: vb674eb8(0xffffffff) = CONST
0x4ebd0xb67: vb674ebd = AND vb674eb8(0xffffffff), vb674ab1(0x4e60)
0x4ebe0xb67: JUMP vb674ebd
Will tackle soon, will have some difficulty.
Would merging basic blocks when there are "chains" (A has B as the only successor block, B has A as the only predecessor block) help?
Not really, it would be a shallow fix. I tried that at some point last year and it didn't give much benefit so I paused it. I think the fix for the current issue will not be too much work, but I need to test it thoroughly.
Closed by https://github.com/nevillegrech/gigahorse-toolchain/pull/136