Stream: git-wasmtime

Topic: wasmtime / issue #5869 Add special cases in the x64 `emit...


view this post on Zulip Wasmtime GitHub notifications bot (Feb 23 2023 at 19:06):

elliottt opened issue #5869:

Feature

The x64 backend has a helper named emit_cmp in inst.isle that is used when emitting comparisons. Currently it will always use x64_cmp to emit the comparison, but for cases of equality comparisons with 0, x64_test would be a better choice. Additionally, the select lowering does not use emit_cmp right now, and could be refactored to do so with this change in place.

Benefit

This will generate better code for cases where emit_cmp is used to compile a use of icmp in the x64 backend.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 23 2023 at 19:06):

elliottt labeled issue #5869:

Feature

The x64 backend has a helper named emit_cmp in inst.isle that is used when emitting comparisons. Currently it will always use x64_cmp to emit the comparison, but for cases of equality comparisons with 0, x64_test would be a better choice. Additionally, the select lowering does not use emit_cmp right now, and could be refactored to do so with this change in place.

Benefit

This will generate better code for cases where emit_cmp is used to compile a use of icmp in the x64 backend.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 23 2023 at 19:06):

elliottt labeled issue #5869:

Feature

The x64 backend has a helper named emit_cmp in inst.isle that is used when emitting comparisons. Currently it will always use x64_cmp to emit the comparison, but for cases of equality comparisons with 0, x64_test would be a better choice. Additionally, the select lowering does not use emit_cmp right now, and could be refactored to do so with this change in place.

Benefit

This will generate better code for cases where emit_cmp is used to compile a use of icmp in the x64 backend.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 23 2023 at 19:06):

elliottt labeled issue #5869:

Feature

The x64 backend has a helper named emit_cmp in inst.isle that is used when emitting comparisons. Currently it will always use x64_cmp to emit the comparison, but for cases of equality comparisons with 0, x64_test would be a better choice. Additionally, the select lowering does not use emit_cmp right now, and could be refactored to do so with this change in place.

Benefit

This will generate better code for cases where emit_cmp is used to compile a use of icmp in the x64 backend.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 17 2023 at 15:50):

jameysharp commented on issue #5869:

The first part of this issue (using test for comparisons with 0) was finished in #6086, but there's still work to do with simplifying the lowering for Cranelift's select instruction on x86.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 21 2023 at 11:03):

Solo-steven commented on issue #5869:

Hi @jameysharp I am interested in this issue, I am a beginner to both compiler backend and isle, so I would like to discuss my solution there before I open PR ~

I think the second part of the issue can be solved by adding a helper for lowering select inst.

(decl lower_select_icmp (Type IcmpCondResult Value Value) InstOutput)
(rule (lower_select_icmp ty (IcmpCondResult.Condition flags cc) x y)
      (with_flags flags (cmove_from_values ty cc x y)))

I think we can change the existing rule to use the helper above, form existed code

https://github.com/bytecodealliance/wasmtime/blob/ed68661976554b8ea967d7d3ca2f2e0741323aad/cranelift/codegen/src/isa/x64/lower.isle#L2084

to use helper above :

(rule (lower (has_type ty (select (maybe_uextend (icmp cc a @ (value_type (fits_in_64 a_ty)) b)) x y)))
      (lower_select_icmp ty (emit_cmp cc a b ) x y))

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2023 at 16:46):

cfallin commented on issue #5869:

@Solo-steven your refactor looks reasonable -- we'd be happy to review a PR with this. Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Sep 10 2024 at 21:51):

sudoHackIn commented on issue #5869:

Hi, @cfallin is this issue still actual or should be closed after Solo-steven's pr is merged?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 10 2024 at 21:55):

cfallin commented on issue #5869:

@sudoHackIn the PR above addresed the second bit (select using the helper) but not the first (using test rather than cmp), so this issue should remain open, I think.


Last updated: Oct 23 2024 at 20:03 UTC