Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate constant to a stack accessing instruction #84

Conversation

akiramenai
Copy link
Collaborator

No description provided.

@akiramenai akiramenai marked this pull request as draft July 7, 2022 19:40
@akiramenai akiramenai force-pushed the dborisenkov-cpr-705-propagate-constants-to-instruction-using branch 5 times, most recently from b8a672f to a0b98e8 Compare July 10, 2022 15:26
@zksync-admin-bot2
Copy link
Collaborator

Benchmark results:

╔═══════════════╡ Size (-%) ╞═══════════════╗
║ Mean                                0.000 ║
║ Best                                0.781 ║
║ Worst                               0.000 ║
║ Total                               0.001 ║
╠══════════════╡ Cycles (-%) ╞══════════════╣
║ Mean                                0.000 ║
║ Best                                0.422 ║
║ Worst                              -0.291 ║
║ Total                               0.000 ║
╚═══════════════════════════════════════════╝

@akiramenai akiramenai force-pushed the dborisenkov-cpr-705-propagate-constants-to-instruction-using branch 3 times, most recently from 8518061 to dbd0d3b Compare July 11, 2022 10:58
@zksync-admin-bot2
Copy link
Collaborator

Benchmark results:

╔═══════════════╡ Size (-%) ╞═══════════════╗
║ Mean                                0.000 ║
║ Best                                0.781 ║
║ Worst                               0.000 ║
║ Total                               0.001 ║
╠══════════════╡ Cycles (-%) ╞══════════════╣
║ Mean                                0.000 ║
║ Best                                0.422 ║
║ Worst                              -0.291 ║
║ Total                               0.000 ║
╚═══════════════════════════════════════════╝

@akiramenai akiramenai marked this pull request as ready for review July 11, 2022 19:48
@akiramenai akiramenai requested a review from lialan July 11, 2022 19:48
Copy link
Contributor

@lialan lialan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit ad hoc when we are trying to identify a specific type of operation in this patch. But I don't have a good way to improve it either (I guess we need to have a lot of tags in the tablegen definitions so we can read those tags in backend, which is still quite clumsy compared to the approach in this PR).

Otherwise, LGTM.

In case a fuction access to an external frame outside of the entry basic
block, the DAG is constructed so that the address is computed in entry
and copied to a register. SelectAddress therefore can't infer that a
constant could be involved in the computation and use Reg + Imm
addressing mode.
The patch introduces a pass that replicates the logic of propagation
constants to a memory accessing operation. If the inital address is
computed by expression 1, and none of it's patrital results is used more
than once, the pass attempts to find expression 2, so that expression 1
is equal to expression 2 + constant. Then it replaces a memory access by
expression 1 to a memory access by expression 2 + constant.
@akiramenai akiramenai force-pushed the dborisenkov-cpr-705-propagate-constants-to-instruction-using branch from dbd0d3b to 0dd53a1 Compare July 13, 2022 13:15
@akiramenai
Copy link
Collaborator Author

@lialan
One day we should move all properties generation as well as instructions mappings to tablegen. Probably a new backend or something is needed, but I think it makes sense to do it gradually.

@zksync-admin-bot2
Copy link
Collaborator

Benchmark results:

╔═══════════════╡ Size (-%) ╞═══════════════╗
║ Mean                                0.000 ║
║ Best                                0.781 ║
║ Worst                               0.000 ║
║ Total                               0.001 ║
╠══════════════╡ Cycles (-%) ╞══════════════╣
║ Mean                                0.000 ║
║ Best                                0.422 ║
║ Worst                              -0.291 ║
║ Total                               0.000 ║
╚═══════════════════════════════════════════╝

@hedgar2017 hedgar2017 merged commit 6a0dec7 into dev-1.1 Jul 13, 2022
@hedgar2017 hedgar2017 deleted the dborisenkov-cpr-705-propagate-constants-to-instruction-using branch July 13, 2022 16:51
akiramenai added a commit that referenced this pull request Dec 1, 2022
Propagate constants to stack address

In case a fuction access to an external frame outside of the entry basic
block, the DAG is constructed so that the address is computed in entry
and copied to a register. SelectAddress therefore can't infer that a
constant could be involved in the computation and use Reg + Imm
addressing mode.
The patch introduces a pass that replicates the logic of propagation
constants to a memory accessing operation. If the inital address is
computed by expression 1, and none of it's patrital results is used more
than once, the pass attempts to find expression 2, so that expression 1
is equal to expression 2 + constant. Then it replaces a memory access by
expression 1 to a memory access by expression 2 + constant.
akiramenai added a commit that referenced this pull request Mar 11, 2024
Propagate constants to stack address

In case a fuction access to an external frame outside of the entry basic
block, the DAG is constructed so that the address is computed in entry
and copied to a register. SelectAddress therefore can't infer that a
constant could be involved in the computation and use Reg + Imm
addressing mode.
The patch introduces a pass that replicates the logic of propagation
constants to a memory accessing operation. If the inital address is
computed by expression 1, and none of it's patrital results is used more
than once, the pass attempts to find expression 2, so that expression 1
is equal to expression 2 + constant. Then it replaces a memory access by
expression 1 to a memory access by expression 2 + constant.
akiramenai added a commit that referenced this pull request Mar 12, 2024
Propagate constants to stack address

In case a fuction access to an external frame outside of the entry basic
block, the DAG is constructed so that the address is computed in entry
and copied to a register. SelectAddress therefore can't infer that a
constant could be involved in the computation and use Reg + Imm
addressing mode.
The patch introduces a pass that replicates the logic of propagation
constants to a memory accessing operation. If the inital address is
computed by expression 1, and none of it's patrital results is used more
than once, the pass attempts to find expression 2, so that expression 1
is equal to expression 2 + constant. Then it replaces a memory access by
expression 1 to a memory access by expression 2 + constant.
akiramenai added a commit that referenced this pull request Mar 15, 2024
Propagate constants to stack address

In case a fuction access to an external frame outside of the entry basic
block, the DAG is constructed so that the address is computed in entry
and copied to a register. SelectAddress therefore can't infer that a
constant could be involved in the computation and use Reg + Imm
addressing mode.
The patch introduces a pass that replicates the logic of propagation
constants to a memory accessing operation. If the inital address is
computed by expression 1, and none of it's patrital results is used more
than once, the pass attempts to find expression 2, so that expression 1
is equal to expression 2 + constant. Then it replaces a memory access by
expression 1 to a memory access by expression 2 + constant.
akiramenai added a commit that referenced this pull request Mar 18, 2024
Propagate constants to stack address

In case a fuction access to an external frame outside of the entry basic
block, the DAG is constructed so that the address is computed in entry
and copied to a register. SelectAddress therefore can't infer that a
constant could be involved in the computation and use Reg + Imm
addressing mode.
The patch introduces a pass that replicates the logic of propagation
constants to a memory accessing operation. If the inital address is
computed by expression 1, and none of it's patrital results is used more
than once, the pass attempts to find expression 2, so that expression 1
is equal to expression 2 + constant. Then it replaces a memory access by
expression 1 to a memory access by expression 2 + constant.
akiramenai added a commit that referenced this pull request Apr 3, 2024
Propagate constants to stack address

In case a fuction access to an external frame outside of the entry basic
block, the DAG is constructed so that the address is computed in entry
and copied to a register. SelectAddress therefore can't infer that a
constant could be involved in the computation and use Reg + Imm
addressing mode.
The patch introduces a pass that replicates the logic of propagation
constants to a memory accessing operation. If the inital address is
computed by expression 1, and none of it's patrital results is used more
than once, the pass attempts to find expression 2, so that expression 1
is equal to expression 2 + constant. Then it replaces a memory access by
expression 1 to a memory access by expression 2 + constant.
akiramenai added a commit that referenced this pull request Apr 4, 2024
Propagate constants to stack address

In case a fuction access to an external frame outside of the entry basic
block, the DAG is constructed so that the address is computed in entry
and copied to a register. SelectAddress therefore can't infer that a
constant could be involved in the computation and use Reg + Imm
addressing mode.
The patch introduces a pass that replicates the logic of propagation
constants to a memory accessing operation. If the inital address is
computed by expression 1, and none of it's patrital results is used more
than once, the pass attempts to find expression 2, so that expression 1
is equal to expression 2 + constant. Then it replaces a memory access by
expression 1 to a memory access by expression 2 + constant.
akiramenai added a commit that referenced this pull request Apr 7, 2024
Propagate constants to stack address

In case a fuction access to an external frame outside of the entry basic
block, the DAG is constructed so that the address is computed in entry
and copied to a register. SelectAddress therefore can't infer that a
constant could be involved in the computation and use Reg + Imm
addressing mode.
The patch introduces a pass that replicates the logic of propagation
constants to a memory accessing operation. If the inital address is
computed by expression 1, and none of it's patrital results is used more
than once, the pass attempts to find expression 2, so that expression 1
is equal to expression 2 + constant. Then it replaces a memory access by
expression 1 to a memory access by expression 2 + constant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants