Stream: git-cranelift

Topic: cranelift / Issue #1341 Improve shift codegen using knowl...


view this post on Zulip GitHub (Jan 13 2020 at 18:07):

abrown opened Issue #1341:

What is the feature or code improvement you would like to do in Cranelift?

As described in https://github.com/WebAssembly/simd/issues/117#issuecomment-573494583, Wasm shifts do extra runtime work to ensure the shift value is within a certain range. This is extra work that could be removed if we had knowledge that the shift value was constant and in the required range. This knowledge could also be used to lower the Wasm shifts to instructions using an immediate.

What is the value of adding this in Cranelift?

Emit faster code.

Do you have an implementation plan, and/or ideas for data structures or algorithms to use?

I think this type of optimization may apply to more than just Wasm shifts so I hope this approach works for those as well:

Have you considered alternative implementations? If so, how are they better or worse than your proposal?

No, open to suggestions.

view this post on Zulip GitHub (Jan 13 2020 at 18:12):

bjorn3 commented on Issue #1341:

https://github.com/bytecodealliance/cranelift/blob/e6e67154c2cd4b68f1045930097df36783cc748c/cranelift-codegen/src/simple_preopt.rs#L560 already performs shl/shr -> shl_imm/shr_imm when possible if opt_level=speed is used.

view this post on Zulip GitHub (Jan 13 2020 at 18:17):

abrown commented on Issue #1341:

Good to know; hadn't seen that!

view this post on Zulip GitHub (Jan 13 2020 at 18:17):

abrown closed Issue #1341:

What is the feature or code improvement you would like to do in Cranelift?

As described in https://github.com/WebAssembly/simd/issues/117#issuecomment-573494583, Wasm shifts do extra runtime work to ensure the shift value is within a certain range. This is extra work that could be removed if we had knowledge that the shift value was constant and in the required range. This knowledge could also be used to lower the Wasm shifts to instructions using an immediate.

What is the value of adding this in Cranelift?

Emit faster code.

Do you have an implementation plan, and/or ideas for data structures or algorithms to use?

I think this type of optimization may apply to more than just Wasm shifts so I hope this approach works for those as well:

Have you considered alternative implementations? If so, how are they better or worse than your proposal?

No, open to suggestions.

view this post on Zulip GitHub (Jan 13 2020 at 18:20):

abrown commented on Issue #1341:

...but not sure that works for SIMD (which I guess I should have mentioned above).

view this post on Zulip GitHub (Jan 13 2020 at 18:20):

abrown reopened Issue #1341:

What is the feature or code improvement you would like to do in Cranelift?

As described in https://github.com/WebAssembly/simd/issues/117#issuecomment-573494583, Wasm shifts do extra runtime work to ensure the shift value is within a certain range. This is extra work that could be removed if we had knowledge that the shift value was constant and in the required range. This knowledge could also be used to lower the Wasm shifts to instructions using an immediate.

What is the value of adding this in Cranelift?

Emit faster code.

Do you have an implementation plan, and/or ideas for data structures or algorithms to use?

I think this type of optimization may apply to more than just Wasm shifts so I hope this approach works for those as well:

Have you considered alternative implementations? If so, how are they better or worse than your proposal?

No, open to suggestions.

view this post on Zulip GitHub (Jan 13 2020 at 18:22):

bjorn3 commented on Issue #1341:

That's probably the condition at https://github.com/bytecodealliance/cranelift/blob/e6e67154c2cd4b68f1045930097df36783cc748c/cranelift-codegen/src/simple_preopt.rs#L571

view this post on Zulip GitHub (Jan 13 2020 at 18:23):

abrown commented on Issue #1341:

Yeah, I guess I could add some code to that function to handle vectors but attempt the same type of translations (instead of mucking around in code_translator.rs).

view this post on Zulip GitHub (Feb 28 2020 at 23:28):

alexcrichton transferred Issue #1341:

What is the feature or code improvement you would like to do in Cranelift?

As described in https://github.com/WebAssembly/simd/issues/117#issuecomment-573494583, Wasm shifts do extra runtime work to ensure the shift value is within a certain range. This is extra work that could be removed if we had knowledge that the shift value was constant and in the required range. This knowledge could also be used to lower the Wasm shifts to instructions using an immediate.

What is the value of adding this in Cranelift?

Emit faster code.

Do you have an implementation plan, and/or ideas for data structures or algorithms to use?

I think this type of optimization may apply to more than just Wasm shifts so I hope this approach works for those as well:

Have you considered alternative implementations? If so, how are they better or worse than your proposal?

No, open to suggestions.


Last updated: Dec 23 2024 at 13:07 UTC