Stream: git-wasmtime

Topic: wasmtime / issue #1102 Fix codegen on a simple branching ...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2021 at 21:15):

bjorn3 commented on issue #1102:

Is this still a problem with the new x64 backend?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2021 at 21:40):

cfallin commented on issue #1102:

I'm not sure if this would use cmov today (it should if the CLIF uses a select op) but the branches should be reasonable (like llvm and gcc) now due to MachBuffer's simplification pass.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2021 at 21:40):

cfallin closed issue #1102:

I thought I'd look into codegen. Consider the following test of a simple branch, where compilers were asked to generate the best code:

int five(int a) {
        return a > 5 ? 8 : a;
}

LLVM generates:

0000000000000000 <five>:
   0:   83 ff 06                cmp    $0x6,%edi
   3:   b8 05 00 00 00          mov    $0x5,%eax
   8:   0f 4c c7                cmovl  %edi,%eax
   b:   c3                      retq

GCC generates:

0000000000000000 <five>:
   0:   89 f8                   mov    %edi,%eax
   2:   83 ff 06                cmp    $0x6,%edi
   5:   ba 08 00 00 00          mov    $0x8,%edx
   a:   0f 4d c2                cmovge %edx,%eax
   d:   c3                      retq

And Cranelift generates (via clang-compiled wasm):

Disassembly of 22 bytes:
   0:   55                      push    rbp
   1:   48 89 e5                mov rbp, rsp
   4:   b8 08 00 00 00          mov eax, 8
   9:   83 ff 05                cmp edi, 5
   c:   7f 04                   jg  0x12
   e:   89 f8                   mov eax, edi
  10:   eb 02                   jmp 0x14
  12:   eb fc                   jmp 0x10
  14:   5d                      pop rbp
  15:   c3                      ret

There are some obvious things to fix up:

view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2021 at 21:46):

akirilov-arm commented on issue #1102:

The first item is covered by #1148.


Last updated: Nov 22 2024 at 16:03 UTC