Skip to content

BitVector Operations #60

Description

@DavePearce

There are various situations where eliminating bitvectors can be quite helpful. Specifically, something like this:

 st := Push4(st,0xffffffff);
 st := And(st);

is replaced with something like this:

 st := Push4(st,0xffffffff);
 st := AndU32(st);

where we have:

    /**
     * Provides an alternative implementation of Bytecode.And specialised to the
     * particular case of converting an arbitrary u256 into a u32 (i.e.
     * stripping out a 4byte function signature for dispatch).
     */
    function AndU32(st: EvmState.ExecutingState): (st': EvmState.State)
    requires st.Operands() >= 2 && st.Peek(0) == (Int.MAX_U32 as u256) {
        var rhs := st.Peek(1);
        var res := rhs % (Int.TWO_32 as u256);
        st.Pop(2).Push(res).Next()
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions