Implement forward substitution of constants in the Cmm mini-inliner
authorJohan Tibell <johan.tibell@gmail.com>
Fri, 6 May 2011 12:13:03 +0000 (14:13 +0200)
committerSimon Marlow <marlowsd@gmail.com>
Wed, 1 Jun 2011 09:56:05 +0000 (10:56 +0100)
Currently the mini-inliner would only forward substitute assignments
to registers that were used exactly once, to not risk duplicating
computation.  For constants there's no such risk so we always
substitute.  Prior to the change the Cmm

    fn
    {
        bits64 a, b;

        a = 1;
        b = a + a;
        RET_N(b);
    }

would be optimized as

    fn()    { []
            }
        ca: _cb::I64 = 1;
            R1 = _cb::I64 + _cb::I64;
            jump (I64[Sp + 0]) ();
    }

but after it would be optimized as

    fn()    { []
            }
        ca: R1 = 2;
            jump (I64[Sp + 0]) ();
    }

Note that this pass does not deal with the now dead assignment.


No differences found