Skip to content

Common subexpression elimination for vasm#6843

Open
octmoraru wants to merge 3 commits into
facebook:masterfrom
octmoraru:cse
Open

Common subexpression elimination for vasm#6843
octmoraru wants to merge 3 commits into
facebook:masterfrom
octmoraru:cse

Conversation

@octmoraru

Copy link
Copy Markdown
Contributor

No description provided.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request has been imported into Phabricator, and discussion and review of the diff will take place at https://reviews.facebook.net/D54435

This diff adds a local common subexpression elimination vasm pass. It has basic
block scope and works as described below:

* searches for binary expressions inside a BB and saves them into a list
* an instruction is considered to be a binary expression if it uses two operands
and defines at least one
* if an expression is already in the saved expression list, it's replaced by a
"nop" instruction
* all uses of registers which are defined by a redundant expression are replaced
with registers defined by the matching expression (i.e. the expression found in
the list)
* if a register used by a saved expression is redefined by another instruction,
the binary expression is removed from the list. This can only happen for
physical registers, which are not in SSA form
* SF registers are also considered non-SSA, since vasm-xls does not support
overlapping liveness intervals for them.
First simplifier is used to remove redundant fallbackcc instructions from a basic
block. The second one transforms a "jcc" into an unconditional "jmp" when a
fallbackcc with the same condition and same SF is present in the same basic
block. Example:

cmpbim     0, [%rbp - 0x8] => %132
fallbackcc NE, (id 0x181f)@7, 1, %132, {%rbp, %r12}
cmpbim     0, [%rbp - 0x8] => %133
jcc        NE, %133, B5, else B12

After vasm-cse:
cmpbim     0, [%rbp - 0x8] => %132
fallbackcc NE, (id 0x181f)@7, 1, %132, {%rbp, %r12}
jcc        NE, %132, B5, else B12

After vasm-simplify:

cmpbim     0, [%rbp - 0x8] => %132
fallbackcc NE, (id 0x181f)@7, 1, %132, {%rbp, %r12}
jmp        B12
@swalk-cavium

Copy link
Copy Markdown
Contributor

Hi,
Does anyone know why this one never landed? Did it corrupt the smashables or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment