Skip to content

Implement forward substitution of constants in the Cmm mini-inliner

While working on a new set of primops for copying arrays, I ran into a Cmm optimizer issue where constants weren't being inlined if the temporary that the constant was assigned to was used more than once. Example:

fn
{
    bits64 a, b;

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

is optimized as

fn()    { []
        }
    ca: _cb::I64 = 1;
        R1 = _cb::I64 + _cb::I64;
        jump (I64[Sp + 0]) ();
}
Trac metadata
Trac field Value
Version 7.0.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC johan.tibell@gmail.com
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information