Skip to content

Problem with intrinsic f32x4_convert_u32x4 in wasm #1322

@vallsv

Description

@vallsv

Hi, i am playing around Wasm and SIMD, trying different implementation in different languages.

I dont know much Rust, but i have noticed a weird conversion with a test.

My Rust source code contains the following explicit intrinsic (and others):

use std::arch::wasm::f32x4_convert_u32x4;

...

let s1 = f32x4_convert_u32x4(...);

First of all, i really like that you have chosen f32x4_convert_u32x4 instead of f32x4_convert_i32x4_u, but it's detail.

Unfortunately It was not processing data as fast as i was expecting.
Checking the assembly with wasm2wat shows the following opcodes.

      i16x8.extract_lane_u 4
      f32.convert_i32_u
      f32x4.splat
      local.get 8
      i16x8.extract_lane_u 5
      f32.convert_i32_u
      f32x4.replace_lane 1
      local.get 8
      i16x8.extract_lane_u 6
      f32.convert_i32_u
      f32x4.replace_lane 2
      local.get 8
      i16x8.extract_lane_u 7
      f32.convert_i32_u
      f32x4.replace_lane 3

Other intrinsic like u32x4_extend_low_u16x8, u16x8_extend_low_u8x16 (and more), was properly converted.

Any idea where could come from the problem?

It maybe have something to do with

pub fn f32x4_convert_u32x4(a: v128) -> v128 {
, other use explicit llvm_ stuffs, but i have no idea how to check any changes anyway.

An equivalent algorithm written in AssemblyScript is generating the following opcode properly:

        f32x4.convert_i32x4_u

I can try to create a very small sample code, it you like.

I am using the following environment.

  • wasm-pack version: 0.10.3
  • rustc version: 1.63.0 (4b91a6ea7 2022-08-08)
  • linux debian 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions