Skip to content

Remember partial literal information #1888

@andreaslyn

Description

@andreaslyn

The x86 emitter is currently only tracking whole-word literal stack elements. It is possible to also keep track of literal values when only parts of the stack element are known. For example the BYTE instruction is known to clear the upper 3 words of the destination stack element. Also when performing a bitwise-and of a stack element and the literal 1, the emitter should be able to deduce that the upper 3 words are cleared in the destination stack element.

A potential solution for this is to add an array of optional word values to the StackElem class,

class StackElem
{
    ...
private:
    ...
    std::array<std::optional<uint64_t>, 4> partial_literal_;
}

If a stack element StackElem e has non-null e.literal_, then we should additionally have e.partial_literal_[i].value() == e.literal_.value()[i] for 0 <= i < 4.

The partial literal information can be used to optimize instructions, by omitting instructions when they are known to be no-operations. If a partial literal word is known to be zero, then it is a no-operation with used as a bitwise-or operand.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions